-
Notifications
You must be signed in to change notification settings - Fork 5
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
basic update translation #59
basic update translation #59
Conversation
src/main/java/com/mongodb/hibernate/internal/translate/TableMutationMqlTranslator.java
Show resolved
Hide resolved
src/main/java/com/mongodb/hibernate/internal/translate/mongoast/AstDocument.java
Show resolved
Hide resolved
607c442
to
6bb7138
Compare
{"update": "books", "updates": [{"q": {"_id": {"$eq": {"$undefined": true}}}, "u": {"$set": {"author": {"$undefined": true}, "publishYear": {"$undefined": true}, "title": {"$undefined": true}}}, "multi": true}]}\ | ||
"""); | ||
} | ||
} |
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.
to prove that the udpating did happen (not one sinlge insertion with latest state), a good feature of hibernate-testing was used here to verify. Note that by default table mutation static update SQL will include all fields for perf reason (db side redundant updating is relatively cheap than dynamic SQL translating)
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.
I tried annotating Book
with @DynamicUpdate
, and it just worked, barring the statementInspector.getSqlQueries
assertion, of course. Should we add a test for that?
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.
good point. I think we should cover this.
There is also a @DynamicInsert
, which won't include fields with null values, so it will align with the null-free insertion case we discussed. I might add it later but not in this PR.
@@ -170,6 +172,46 @@ void testSimpleDeletion() { | |||
} | |||
} | |||
|
|||
@Nested | |||
class UpdateTests { |
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.
@Nested
is used to accommodate the future new testing case after optimistic locking
feature is taken into consideration, even though currently there is only one testing case in this PR.
src/integrationTest/java/com/mongodb/hibernate/BasicCRUDTests.java
Outdated
Show resolved
Hide resolved
# Conflicts: # src/integrationTest/java/com/mongodb/hibernate/BasicCrudIntegrationTests.java
src/integrationTest/java/com/mongodb/hibernate/BasicCrudIntegrationTests.java
Outdated
Show resolved
Hide resolved
…ationTests.java Co-authored-by: Maxim Katcharov <[email protected]>
src/main/java/com/mongodb/hibernate/internal/translate/AbstractMqlTranslator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/mongodb/hibernate/internal/translate/AbstractMqlTranslator.java
Outdated
Show resolved
Hide resolved
src/integrationTest/java/com/mongodb/hibernate/BasicCrudIntegrationTests.java
Outdated
Show resolved
Hide resolved
{"update": "books", "updates": [{"q": {"_id": {"$eq": {"$undefined": true}}}, "u": {"$set": {"author": {"$undefined": true}, "publishYear": {"$undefined": true}, "title": {"$undefined": true}}}, "multi": true}]}\ | ||
"""); | ||
} | ||
} |
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.
I tried annotating Book
with @DynamicUpdate
, and it just worked, barring the statementInspector.getSqlQueries
assertion, of course. Should we add a test for that?
src/integrationTest/java/com/mongodb/hibernate/BasicCrudIntegrationTests.java
Outdated
Show resolved
Hide resolved
The last reviewed commit is e988b33. |
I will take myself off as a formal reviewer for now - if a secondary is needed, please do add me once the primary is complete. |
…ationTests.java Co-authored-by: Valentin Kovalenko <[email protected]>
I've finished resolving the comments, so the PR is ready for a new book. |
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.
Finished the first round of reivew comments resolving
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.
The last reviewed commit is 90d7876.
src/integrationTest/java/com/mongodb/hibernate/BasicCrudIntegrationTests.java
Outdated
Show resolved
Hide resolved
src/main/java/com/mongodb/hibernate/internal/translate/AbstractMqlTranslator.java
Outdated
Show resolved
Hide resolved
src/integrationTest/java/com/mongodb/hibernate/BasicCrudIntegrationTests.java
Outdated
Show resolved
Hide resolved
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.
The last reviewed commit is 3c4e08f.
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.
The last reviewed commit is 8803d30.
https://jira.mongodb.org/browse/HIBERNATE-19
a straightforward PR