Skip to content

Commit

Permalink
With statement ToSQL rebind is missing
Browse files Browse the repository at this point in the history
The rebind param is not applied inside the ToSQL func, hence the
ToSQL is binded with DOLLAR for postgres.
  • Loading branch information
nuwaida authored and ido50 committed Dec 13, 2023
1 parent 9605fd9 commit 2f64be1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions with.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ func (stmt *WithStmt) ToSQL(rebind bool) (asSQL string, bindings []interface{})
bindings = append(bindings, mainBindings...)

asSQL = strings.Join(clauses, " ")
if db, ok := stmt.execer.(*sqlx.DB); ok {
asSQL = db.Rebind(asSQL)
} else if tx, ok := stmt.execer.(*sqlx.Tx); ok {
asSQL = tx.Rebind(asSQL)
if rebind {

Check failure on line 82 in with.go

View workflow job for this annotation

GitHub Actions / Build

if statements should only be cuddled with assignments used in the if statement itself (wsl)
if db, ok := stmt.execer.(*sqlx.DB); ok {
asSQL = db.Rebind(asSQL)
} else if tx, ok := stmt.execer.(*sqlx.Tx); ok {
asSQL = tx.Rebind(asSQL)
}
}

return asSQL, bindings
Expand Down

0 comments on commit 2f64be1

Please sign in to comment.