-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ANY in condition DSL #413
Comments
I wouldn't say it's a bug because |
hello @flash-gordon , filter_type_id = "test"
states
.where { self[:filter_type_ids].any(filter_type_id) | self[:filter_type_ids].is(nil) }
.order(:order) I get following error: Failure/Error:
states
.where { self[:filter_type_ids].any(filter_type_id) | self[:filter_type_ids].is(nil) }
.order(:order).to_a
NameError:
wrong constant name []
types.const_get(type_name) if types.const_defined?(type_name) |
@wuarmin sorry for the confusion, I think the truth is in the middle: there's .where { filter_type_ids.is(nil) | filter_type_ids.in(*filter_type_id) } There's no difference between |
Yes, there's no difference, but I cannot write it that way: .where { filter_type_ids.is(nil) | filter_type_ids.in(*filter_type_id) } produces OR ("states"."filter_type_ids" IN ARRAY['test']::text[]) which is invalid and not what I need, I need ('test' = ANY("states"."filter_type_ids")) What about adding any to rom-sql API? |
I'm just saying it should have no difference at the database level. You can use inline SQL with backticks: where { `filter_type_ids is null or filter_type_ids = any(array([#{filter_type_id.map { "'#{_1}'" }.join(',') }]))` } A PR with adding |
Describe the bug
Following code
produces following sql:
but the resulting sql should be following:
If I change the order of the
OR
-conditionit works.
My environment
The text was updated successfully, but these errors were encountered: