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 expect the args given to Joins to behave similarly to the args given to Where. In the Playground shown above the behavior for Slice arguments appears to differ. The behavior also differs from GORM V1 (not shown in playground but I have verified this locally).
Expected behavior: query.Joins("JOIN X ON X.id = y.x_id AND x.some_column IN (?)", []uint{1, 2}) would generate a fragment like x.some_column IN (1, 2).
This is observed in GORM V1, and in similar Where usage (within respect to the some_column IN (?)).
Problematic behavior: query.Joins("JOIN X ON X.id = y.x_id AND x.some_attribute IN (?)", []uint{1, 2}) generates x.some_column IN ((1, 2)). This will likely result in an error within the DB from an unexpected type.
This can be worked around by simply writing the statement as query.Joins(JOIN X ON X.id = y.x_id AND x.some_attribute IN ?, []uint{1, 2}) (omitting parenthesis around ?).
Perhaps in Where and GORM V1 parentheses wrapping the ? are detected and none are added unless necessary?
The text was updated successfully, but these errors were encountered:
GORM Playground Link
go-gorm/playground#291
Description
I expect the args given to
Joins
to behave similarly to the args given toWhere
. In the Playground shown above the behavior for Slice arguments appears to differ. The behavior also differs from GORM V1 (not shown in playground but I have verified this locally).Expected behavior:
query.Joins("JOIN X ON X.id = y.x_id AND x.some_column IN (?)", []uint{1, 2})
would generate a fragment likex.some_column IN (1, 2)
.This is observed in GORM V1, and in similar
Where
usage (within respect to thesome_column IN (?)
).Problematic behavior:
query.Joins("JOIN X ON X.id = y.x_id AND x.some_attribute IN (?)", []uint{1, 2})
generatesx.some_column IN ((1, 2))
. This will likely result in an error within the DB from an unexpected type.This can be worked around by simply writing the statement as
query.Joins(
JOIN X ON X.id = y.x_id AND x.some_attribute IN ?, []uint{1, 2})
(omitting parenthesis around?
).Perhaps in
Where
and GORM V1 parentheses wrapping the?
are detected and none are added unless necessary?The text was updated successfully, but these errors were encountered: