Skip to content

Support for ANY in condition DSL #413

@wuarmin

Description

@wuarmin

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions