-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Support Or and nested queries #13
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
Conversation
marian-stykhun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Few minor changes
| op: Optional[str] = None, | ||
| value: Optional[Any] = None, | ||
| filter: Optional[FieldFilter] = None, | ||
| filter: Union[FieldFilter, And, Or, None] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not critical
May we use OptionalUnion[FieldFilter, And, Or] ?
As None is not a type. and using Union[type, None] is outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional is just shorthand for Union[x, None].
In this case it wouldn't make things much shorter as you end up with Optional[Union[x]].
It's not deprecated either to use Union
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't
Thats why it isnt critical.
But even python's creators decided that it is bad design :)
| if filter is not None: | ||
| field, op, value = filter.field_path, filter.op_string, filter.value | ||
| if field is None or op is None or value is None: | ||
| if filter is None and (field is None or op is None or value is None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filter is None and not any([field, op, value])?
Or we need i direct check is None ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes as we cannot rely on the truthiness of value.
We are explicitly checking for if the params have not been provided.
In our tools we are requiring more complex queries than single FieldFilters, or a group joined in a kind of "And" behaviour.
Because Firestore supports more complex queries than this, and we are using them, this PR updates mockfirestore so that we can effortlessly use these nice features without having to craft convoluted tests.
Of note is that I am supporting the native Firestore objects, not creating any new kinds of query objects.
I've added a test to show the kind of usage now supported.