Skip to content

Commit 2f64be1

Browse files
nuwaidaido50
authored andcommitted
With statement ToSQL rebind is missing
The rebind param is not applied inside the ToSQL func, hence the ToSQL is binded with DOLLAR for postgres.
1 parent 9605fd9 commit 2f64be1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

with.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ func (stmt *WithStmt) ToSQL(rebind bool) (asSQL string, bindings []interface{})
7979
bindings = append(bindings, mainBindings...)
8080

8181
asSQL = strings.Join(clauses, " ")
82-
if db, ok := stmt.execer.(*sqlx.DB); ok {
83-
asSQL = db.Rebind(asSQL)
84-
} else if tx, ok := stmt.execer.(*sqlx.Tx); ok {
85-
asSQL = tx.Rebind(asSQL)
82+
if rebind {
83+
if db, ok := stmt.execer.(*sqlx.DB); ok {
84+
asSQL = db.Rebind(asSQL)
85+
} else if tx, ok := stmt.execer.(*sqlx.Tx); ok {
86+
asSQL = tx.Rebind(asSQL)
87+
}
8688
}
8789

8890
return asSQL, bindings

0 commit comments

Comments
 (0)