-
Notifications
You must be signed in to change notification settings - Fork 892
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
Refactor Filters #1894
Refactor Filters #1894
Conversation
This makes it possible to validate arguments once rather than per-document.
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.
HUGE fan of this in general. My main question is whether we really need to keep NullFilter
and NaNFilter
... 😄
@@ -1283,7 +1284,7 @@ export class JsonProtoSerializer { | |||
|
|||
// visible for testing | |||
toRelationFilter(filter: Filter): api.Filter { |
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.
toRelationFilter => toFieldFilter? And I guess this is preexisting weirdness but it really seems like the instanceof check should go in the caller and the filter
parameter here should be FieldFilter
, not Filter
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.
After removing NanFilter
and NullFilter
this becomes toUnaryOrFieldFilter
because it now has to handle the difference between proto UnaryFilter and
FieldFilter`.
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.
LGTM. Thanks!
#1894 introduced a regression that made persisted queries deserialize incorrectly. Fix the regression and add tests. The root cause is that the refactoring introduced a type hierarchy of classes derived from `FieldFilter`, but serializer always deserializes persisted filters to the base class `FieldFilter`, never to the derived types. This would have affected array-contains queries, in queries, and key field queries. Fixes #1904.
* Rename relation_filter.{h,cc} to field_filter.{h,cc} * Rename RelationFilter to FieldFilter * Move Filter::Create to FieldFilter * Port api::Query::ValidateNewFilter * Add ArrayContainsFilter * Add KeyFieldFilter * Make FieldFilter constructor protected * Port FieldFilter refactor from the JS SDK firebase/firebase-js-sdk#1894 * Add spec test from firebase/firebase-js-sdk#1913 * Accept array-contains as a synonym for array_contains
This is a bunch of related changes:
Each commit describes what it does individually.
cc @thebrianchen