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

feat(datastore): EntityFilter for AND/OR queries #7589

Merged
merged 9 commits into from
Apr 3, 2023
Merged

feat(datastore): EntityFilter for AND/OR queries #7589

merged 9 commits into from
Apr 3, 2023

Conversation

bhshkh
Copy link
Contributor

@bhshkh bhshkh commented Mar 19, 2023

Adding new method 'FilterEntity' to Query which can be used to construct composite queries.
Adding the following new structs to be used with FilterEntity

  • AND
  • OR
  • PropertyFilter

@bhshkh bhshkh requested review from telpirion and a team as code owners March 19, 2023 04:30
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: datastore Issues related to the Datastore API. labels Mar 19, 2023
@bhshkh bhshkh requested a review from enocom March 19, 2023 04:31
datastore/query.go Outdated Show resolved Hide resolved
datastore/query.go Outdated Show resolved Hide resolved
datastore/integration_test.go Show resolved Hide resolved
datastore/query.go Outdated Show resolved Hide resolved
Filters []EntityFilter
}

func (OR) isCompositeFilter() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: it looks like this method is only used to satisfy the CompositeFilter interface above. Same with AND below. Seems to me that you should be able to have both OR and AND structs fulfill the same interface without creating a dummy method. Try to remove isCompositeFilter().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On removing, I see error:
cannot use &OR{…} (value of type *OR) as CompositeFilter value in struct literal: *OR does not implement CompositeFilter (missing method isCompositeFilter)

datastore/query.go Outdated Show resolved Hide resolved
datastore/query.go Outdated Show resolved Hide resolved
return nil, errors.New("datastore: empty query filter field name")
}
v, err := interfaceToProto(reflect.ValueOf(qf.Value).Interface(), false)
pbFilter, err := qf.toProto()
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Nice refactor here!

datastore/query_test.go Outdated Show resolved Hide resolved
datastore/query_test.go Outdated Show resolved Hide resolved
Copy link

@danieljbruce danieljbruce left a comment

Choose a reason for hiding this comment

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

Looks good!

datastore/query.go Show resolved Hide resolved
datastore/query.go Show resolved Hide resolved
datastore/integration_test.go Show resolved Hide resolved
datastore/integration_test.go Show resolved Hide resolved
datastore/integration_test.go Outdated Show resolved Hide resolved
datastore/integration_test.go Outdated Show resolved Hide resolved
datastore/query.go Show resolved Hide resolved
datastore/query_test.go Outdated Show resolved Hide resolved
datastore/query_test.go Show resolved Hide resolved
datastore/query.go Outdated Show resolved Hide resolved
datastore/query.go Outdated Show resolved Hide resolved
datastore/query.go Outdated Show resolved Hide resolved
@enocom
Copy link
Member

enocom commented Mar 24, 2023

@bhshkh When you're ready for another round of reviews, just "Re-Request Review" on the side panel above and I'll take a look.

@bhshkh bhshkh requested review from telpirion and enocom March 25, 2023 01:36
Copy link
Member

@enocom enocom left a comment

Choose a reason for hiding this comment

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

A couple of minor nits, but big picture looks great.

datastore/query.go Outdated Show resolved Hide resolved
datastore/query.go Outdated Show resolved Hide resolved
datastore/query_test.go Outdated Show resolved Hide resolved
@bhshkh bhshkh enabled auto-merge (squash) March 28, 2023 10:57
datastore/query.go Outdated Show resolved Hide resolved
datastore/query.go Outdated Show resolved Hide resolved
datastore/query.go Show resolved Hide resolved
@bhshkh bhshkh requested a review from codyoss March 30, 2023 10:17
@bhshkh bhshkh disabled auto-merge March 30, 2023 18:08
@bhshkh bhshkh enabled auto-merge (squash) March 31, 2023 07:24
@bhshkh bhshkh merged commit 81f7c87 into googleapis:main Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants