Skip to content
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

Merged
merged 10 commits into from
Jun 21, 2019
Merged

Refactor Filters #1894

merged 10 commits into from
Jun 21, 2019

Conversation

wilhuff
Copy link
Contributor

@wilhuff wilhuff commented Jun 19, 2019

This is a bunch of related changes:

  • Extract specific filter types for each special kind of operation
  • Rename things to match
  • Simplify

Each commit describes what it does individually.

cc @thebrianchen

Copy link
Contributor

@mikelehen mikelehen left a 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... 😄

packages/firestore/src/api/database.ts Outdated Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
@@ -1283,7 +1284,7 @@ export class JsonProtoSerializer {

// visible for testing
toRelationFilter(filter: Filter): api.Filter {
Copy link
Contributor

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

Copy link
Contributor Author

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`.

packages/firestore/src/core/query.ts Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
packages/firestore/src/core/query.ts Outdated Show resolved Hide resolved
packages/firestore/src/model/field_value.ts Show resolved Hide resolved
@mikelehen mikelehen assigned wilhuff and unassigned mikelehen Jun 20, 2019
@mikelehen
Copy link
Contributor

BOOM!
image

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

packages/firestore/src/core/query.ts Show resolved Hide resolved
@wilhuff wilhuff merged commit 74a397a into master Jun 21, 2019
@wilhuff wilhuff deleted the wilhuff/filters branch June 21, 2019 14:57
var-const added a commit that referenced this pull request Jun 25, 2019
#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.
wilhuff added a commit to firebase/firebase-ios-sdk that referenced this pull request Jul 15, 2019
wilhuff added a commit to firebase/firebase-ios-sdk that referenced this pull request Jul 20, 2019
* 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
@firebase firebase locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants