subquery not_in returns NULL
Closed this issue · 1 comments
hrasguido commented
Issue
When I use "not_in" the sql result is NULL. But if I use only "in", the result works fine
Reproduction
table1.joins(:table2)
.where.has{ id.in table3.select(:table1_id).where(table3_id: 162) }
Result
SELECT "table1".* FROM "table1" INNER JOIN "table2" ON "table2"."table1_id" = "table1"."id"
WHERE "table1"."id" IN (SELECT "table3"."table1_id" FROM "table3" WHERE "table3"."table3_id" = 162)
But when I use not_in
table1.joins(:table2)
.where.has{ id.not_in table3.select(:table1_id).where(table3_id: 162) }
Result
SELECT "table1".* FROM "table1" INNER JOIN "table2" ON "table2"."table1_id" = "table1"."id"
WHERE "table1"."id" NOT IN (NULL)
rzane commented
Releasing a new version momentarily!