You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the Where query builder built in to pop, however I've run into a case where you cannot provide the correct arguments to the query.
A simple example is:
q.Where("id in (?) or b in (?)", args...)
Builds the query: select from model where id in ($1, $2) or b in ($3). However, as I only supplied two argument placeholders, I would only expect two args, select from model where id in ($1) or b in ($2).
The code causing this is in query.go. The where logic should not change the amount of ? placeholders the caller expected, as then the caller may not be able to supply the correct arguments.
....
if inRegex.MatchString(stmt) {
var inq []string
for i := 0; i < len(args); i++ {
inq = append(inq, "?")
}
qs := fmt.Sprintf("(%s)", strings.Join(inq, ","))
stmt = strings.Replace(stmt, "(?)", qs, 1)
}
...
The text was updated successfully, but these errors were encountered:
Jwonsever
changed the title
Pop WHERE arguments makes it impossible to use multiple IN clauses.
Pop WHERE arguments makes it impossible to OR multiple IN clauses.
Dec 19, 2020
I am trying to use the Where query builder built in to pop, however I've run into a case where you cannot provide the correct arguments to the query.
A simple example is:
q.Where("id in (?) or b in (?)", args...)
Builds the query:
select from model where id in ($1, $2) or b in ($3)
. However, as I only supplied two argument placeholders, I would only expect two args,select from model where id in ($1) or b in ($2)
.The code causing this is in query.go. The where logic should not change the amount of ? placeholders the caller expected, as then the caller may not be able to supply the correct arguments.
The text was updated successfully, but these errors were encountered: