-
-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Labels
Description
Describe the bug
Following code
filter_type_id = "test"
states
.where { filter_type_ids.any(filter_type_id) | filter_type_ids.is(nil) }
.order(:order)
produces following sql:
SELECT "states"."id", "states"."name", "states"."order", "states"."filter_type_ids"
FROM "states"
WHERE ("states"."filter_type_ids" IS NULL)
ORDER BY "order"
but the resulting sql should be following:
SELECT "states"."id", "states"."name", "states"."order", "states"."filter_type_ids"
FROM "states"
WHERE (('test' = ANY("states"."filter_type_ids")) OR ("states"."filter_type_ids" IS NULL))
ORDER BY "order"
If I change the order of the OR
-condition
states
.where { filter_type_ids.is(nil) | filter_type_ids.any(filter_type_id) }
.order(:order)
it works.
My environment
- Ruby version: 3.1.2
- OS: ruby:3.1.2-slim-buster