Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Increase operator support #14

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

soderluk
Copy link

@soderluk soderluk commented May 7, 2022

Add support for IN and NOT IN operators when querying for arrays.
Also add the "reverse" of IN and NOT IN, i.e. contains and not contains, which checks if the given parameter is found in an array of
the model attribute.

@lietu
Copy link

lietu commented May 9, 2022

I would prefer to replace spaces in dict keys with _, and since there are so many now and they don't match so well to the internal names used in Arango it might be best if the keys were typed as an Enum defining the valid values

Operators.IN
Operators.GT
Operators.GTE

or something?

People would still be free to use the string values if they wanted to, but we'd have typing to assist.

@soderluk
Copy link
Author

soderluk commented May 9, 2022

@lietu True, good idea as well. What do you think about the "contains" support? I didn't really think of any better way of "reversing" the fields.

@lietu
Copy link

lietu commented May 9, 2022

contains seems logical and useful, but I think I've seen it mostly called something like "any of" and maybe "none of" - no strong opinions to any direction on that

@soderluk
Copy link
Author

soderluk commented May 9, 2022

@lietu Did some refactoring on this. Review when convenient. Thanks!

# Operators.GTE (>=)
# Operators.IN
# Operators.NOT_IN
# Operators.ALL_IN
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much poker? 😄

@lietu
Copy link

lietu commented May 9, 2022

Except the 2 references to ALL_IN I think this looks pretty good. Personally I would probably from Operators import IN etc. to reduce verbosity, but I don't think it matters really. However I'd like to get feedback from @joakimnordling as well when he has the time.

@soderluk
Copy link
Author

soderluk commented May 9, 2022

Except the 2 references to ALL_IN I think this looks pretty good. Personally I would probably from Operators import IN etc. to reduce verbosity, but I don't think it matters really. However I'd like to get feedback from @joakimnordling as well when he has the time.

What 2 references? The other one is NOT_IN and the other ALL_IN :)

@soderluk
Copy link
Author

soderluk commented May 9, 2022

@lietu also, I removed the "reverse" order of the array comparison. It's not necessary now that we support all the array comparison operators.

arangodantic/operators.py Outdated Show resolved Hide resolved
Add support for `IN` and `NOT IN` operators when querying for arrays.
Also add the "reverse" of `IN` and `NOT IN`, i.e. `contains` and `not
contains`, which checks if the given parameter is found in an array of
the model attribute.
Add more array comparison operators and move them into their own enum
class for easier usage.
The array comparison happens in the same way as normal comparison. Now
that we have support for the different types, the comparison should be
done correctly.
@soderluk soderluk force-pushed the add_operator_support branch from 473d2ab to fb85613 Compare November 6, 2022 09:27
Add more operators, such as LIKE, NOT LIKE, =~ and !~. The latter are
for regular expression matches.

Also add support for all the array comparison operators. The array
operators are a bit special, since the ANY, ALL and NONE requires an
additional operator, such as ==, !=, >, etc. to match against the
individual keys in the array.

Add test cases for all the operators from ArangoDB documentation, to
keep the tests up to par with the docs.
@soderluk
Copy link
Author

soderluk commented Nov 6, 2022

@joakimnordling The tests are now updated and more operator support added.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants