Dynamically build conditions #2008
MentiHelgi
started this conversation in
General
Replies: 1 comment 3 replies
-
It sounds like |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi. I am struggling with building (recursively) dynamic conditions (they can be nested).
I have a structure, parsed by an external library that looks something like this:
The method I opted for was to do recursion, that is iterate over the array. When I meet a logical operator (and, or, not), I recurse and build the child expressions, which are then returned. This will look something like this:
The problem is that this only works for value operators. I can't get this to work for logical operators. I would have expected to be able to call some method like
Sequel.and
that takes an array of expressions and returns a Sequel AND object that would just translate to SQL such as:foo = 'bar' AND baz = 'qux'
.Anyone have any idea what I need to do for
AND
,OR
andNOT
to achieve this?Beta Was this translation helpful? Give feedback.
All reactions