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

Fix #158: support empty Projection clause; add full decoding of projection definition (but not yet processing) #286

Merged
merged 14 commits into from
Mar 24, 2023

Conversation

tatu-at-datastax
Copy link
Contributor

@tatu-at-datastax tatu-at-datastax commented Mar 22, 2023

What this PR does:

Adds support for optional empty "projection" parameter, validation that if passed its JSON Object.
Serves as the base for actual projection implementation

Which issue(s) this PR fixes:
Fixes #158

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

LGTM so far 👍

@tatu-at-datastax
Copy link
Contributor Author

Right now this will only support empty "projection", fail on non-empty. I will create a follow-up for completing handling but want to get this merged so that we can reconcile work for sorting and keep PRs from getting huge.

@tatu-at-datastax tatu-at-datastax marked this pull request as ready for review March 24, 2023 16:09
@tatu-at-datastax tatu-at-datastax requested a review from a team as a code owner March 24, 2023 16:09
@tatu-at-datastax tatu-at-datastax changed the title (WIP) Fix #158: support empty Projection clause Fix #158: support empty Projection clause; add full decoding of projection definition (but not yet processing) Mar 24, 2023
@vkarpov15
Copy link
Collaborator

On a related note @tatu-at-datastax , what do you think about adding support for empty options object as well? Right now, Mongoose always sends empty options to deleteOne(), for example, which always fails. We can strip that out in the driver layer, but I think it would be better for the jsonapi to handle that.

@tatu-at-datastax
Copy link
Contributor Author

On a related note @tatu-at-datastax , what do you think about adding support for empty options object as well? Right now, Mongoose always sends empty options to deleteOne(), for example, which always fails. We can strip that out in the driver layer, but I think it would be better for the jsonapi to handle that.

Sounds like a good idea to me; if you can file a Github issue, cc Aaron it can be discussed. Uniformity is good I think, as my first impression.

return new FindOperation(
commandContext,
filters,
command.buildProjector(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this is correct, the FindOperation inside FindOneAndUpdate should be passed identityProjector() because the document is merged with updates. Need to apply projection on top document that is returned [here] (https://github.com/stargate/jsonapi/blob/b6d4f73be517cf2e90fb50384e8e60f411754f99/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/ReadAndUpdateOperation.java#L183). This needs Projection passed into ReadAndUpdateOperation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, will change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed in 2 commits.

@@ -181,6 +182,10 @@ private Uni<UpdatedDocument> processUpdate(
if (returnDocumentInResponse) {
documentToReturn =
returnUpdatedDocument ? updatedDocument : originalDocument;
// In this case, we'll apply projection on before/after document (was
// not applied during find() phase
DocumentProjector projector = findOperation().projection();
Copy link
Contributor

@maheshrajamani maheshrajamani Mar 24, 2023

Choose a reason for hiding this comment

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

Think ReadAndUpdateOperation should get the projection in it's constructor? As stated in your comment is it part of different commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, this will not work; it's the identity one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Approved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline, yes, this would not work. Commented out and will resolve in follow-up PR; merging to avoid blocking.

@tatu-at-datastax tatu-at-datastax merged commit 7870162 into main Mar 24, 2023
@tatu-at-datastax tatu-at-datastax deleted the tatu/158-support-projection-2 branch March 24, 2023 19:10
@tatu-at-datastax
Copy link
Contributor Author

Merged; had to re-run cancelled CI once.

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

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.

Support missing or empty projection clause for commands
3 participants