Replies: 2 comments
-
DB[:entities].where(DB.
from(Sequel.sqlite_json_op(Sequel[:entities][:entry]).get_json("$.array").each.as(:json_entries)).
select(1).
where(Sequel[:json_entries][:value] => "some_value").exists
).select(:id)
# SELECT id FROM `entities` WHERE (EXISTS (
# SELECT 1 FROM json_each((`entities`.`entry` -> '$.array')) AS 'json_entries'
# WHERE (`json_entries`.`value` = 'some_value')
# )) |
Beta Was this translation helpful? Give feedback.
0 replies
-
thank you very much! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, I am trying to convert this statement into sequel dsl:
this is basically filtering by the json column entry, where an array inside exists which should contain a value.
I can't get my head around how to construct this query using seuqel's dsl. Best I got so far is:
However, this gives me:
NoMethodError: private method 'select' called for #<Sequel::SQL::Function:0x7ca9c253>
Can anybody help me to transform the query?
thanks alot
Beta Was this translation helpful? Give feedback.
All reactions