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
{{ message }}
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
Squeel 1.2.3 + AR 4.1.14 seems to generate invalid SQL when joining with an association that includes both simple condition and complex IN + OR condition.
E.g. a Parent model with has_many :complex_scoped_models, ->{ where(flag: true).where(field: ['test1', 'test2', nil]) }, class_name: 'Model'
will generate following SQL when doing Parent.all.joins(:complex_scoped_models).first:
SELECT "parents".* FROM "parents" INNER JOIN "models" ON "models"."parent_id" = "parents"."id" AND "models"."flag" = 't', (("models"."field" IN ('test1', 'test2') OR "models"."field" IS NULL)) ORDER BY "parents"."id" ASC LIMIT 1
Note the comma after "models"."flag" = 't', when there should be another AND.
Same scope on the model itself (without an association) seems to be working.
Squeel 1.2.3 + AR 4.1.14 seems to generate invalid SQL when joining with an association that includes both simple condition and complex IN + OR condition.
E.g. a
Parent
model withhas_many :complex_scoped_models, ->{ where(flag: true).where(field: ['test1', 'test2', nil]) }, class_name: 'Model'
will generate following SQL when doing
Parent.all.joins(:complex_scoped_models).first
:Note the comma after
"models"."flag" = 't'
, when there should be another AND.Same scope on the model itself (without an association) seems to be working.
I've put up a test bench for the issue, you can see full code and test at https://github.com/azhi/squeel_complex_scope_association_test.
PS: it looks similar to an error pointed by @vellotis in #361 (comment).
The text was updated successfully, but these errors were encountered: