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

Support Stream as return type to datastore queries #551

Merged
merged 9 commits into from
Jul 28, 2021
Merged

Support Stream as return type to datastore queries #551

merged 9 commits into from
Jul 28, 2021

Conversation

zhumin8
Copy link
Contributor

@zhumin8 zhumin8 commented Jul 27, 2021

This is fix for #452.
Fixed code in GqlDatastoreQuery and PartTreeDatastoreQuery to support for Stream as a return type and added corresponding unit tests and integration tests.

@zhumin8 zhumin8 requested review from elefeint and meltsufin July 27, 2021 16:37
Copy link
Member

@meltsufin meltsufin 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 to me. I would just encourage to also update Datastore documentation and one of the samples.

@zhumin8
Copy link
Contributor Author

zhumin8 commented Jul 27, 2021

Good idea. I'll look into updating Datastore documentation and sample.

Copy link
Contributor

@elefeint elefeint left a comment

Choose a reason for hiding this comment

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

The code looks great! I only have minor feedback.

@@ -439,7 +444,7 @@ public Cursor getCursor() {

structuredQueryBuilder.setKind(PartTreeDatastoreQuery.this.datastorePersistentEntity.kindName());

singularResult = (!isCountingQuery && collectionType == null) && !PartTreeDatastoreQuery.this.tree.isDelete();
singularResult = (!isCountingQuery && collectionType == null && !isStreamQuery) && !PartTreeDatastoreQuery.this.tree.isDelete();
Copy link
Contributor

Choose a reason for hiding this comment

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

This boolean expression is getting too complicated. Since we are touching this line, could you refactor it into an if/else statement, with a view for reducing the negations ("if it's a counting query or a stream query, then singlarResult = false") is easier on the mind than "if it's not a counting query and it's not a stream query, singlarResult = true".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll take the chance to make it easier to read.

Stream<TestEntity> findStreamByColor(String color);

@Query("select * from test_entities_ci where color = @color")
Stream<TestEntity> findByColorStream(@Param("color") String color);
Copy link
Contributor

Choose a reason for hiding this comment

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

The difference between findStreamByColor and findByColorStream is very subtle. Could you rename findByColorStream to something like findGqlStreamByColor?

And possibly rename findStreamByColor to findPartTreeStreamByColor, so the targeted functionality is very clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, do you think I should also make a comment here say these method are to test Stream as return type for GQL query and PartTree query respectively? Or is it too much?

Copy link
Contributor

Choose a reason for hiding this comment

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

no, I think the descriptive naming you have right now is great.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 28, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

89.3% 89.3% Coverage
0.0% 0.0% Duplication

Copy link
Member

@meltsufin meltsufin left a comment

Choose a reason for hiding this comment

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

Nice work!

@zhumin8 zhumin8 merged commit b90ed85 into GoogleCloudPlatform:main Jul 28, 2021
zhumin8 added a commit that referenced this pull request Jul 29, 2021
To fix DatastoreSampleApplicationIntegrationTests broke by #551.
kateryna216 added a commit to kateryna216/spring-cloud-gcp that referenced this pull request Oct 20, 2022
…rm#551)

fixes GoogleCloudPlatform#452.
Fixed code in GqlDatastoreQuery and PartTreeDatastoreQuery to support for Stream as a return type and added corresponding unit tests and integration tests.
kateryna216 added a commit to kateryna216/spring-cloud-gcp that referenced this pull request Oct 20, 2022
To fix DatastoreSampleApplicationIntegrationTests broke by GoogleCloudPlatform#551.
prash-mi pushed a commit that referenced this pull request Jun 20, 2023
Bumps [mockito-core](https://github.com/mockito/mockito) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v4.6.0...v4.6.1)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants