feat: [#712,#713] facades.Orm().Query() and facades.DB() Support Updating JSON Columns#1092
Merged
feat: [#712,#713] facades.Orm().Query() and facades.DB() Support Updating JSON Columns#1092
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for updating JSON columns by allowing the use of the "->" syntax to target specific keys within the JSON object. Key changes include:
- Implementing the CompileJsonColumnsUpdate method in both grammar and its mocks.
- Adding an error constant for JSON column update failures.
- Updating the query and test files to incorporate the new JSON column update logic.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mocks/database/driver/JsonGrammar.go | Added mock function and helper methods for CompileJsonColumnsUpdate. |
| mocks/database/driver/Grammar.go | Added mock function and helper methods for CompileJsonColumnsUpdate. |
| errors/list.go | Added a new error constant for JSON column update invalid values. |
| database/gorm/query.go | Updated query implementation to compile JSON column updates when values are maps. |
| database/db/query_test.go | Updated tests to set expectations for JSON column update behavior. |
| database/db/query.go | Updated update builder to run JSON column update compilation. |
| database/db/expression.go | Minor update wrapping gorm.Expr in a new Expr type. |
| contracts/database/driver/grammar.go | Added a new interface method for JSON column update in the driver grammar. |
Comments suppressed due to low confidence (1)
contracts/database/driver/grammar.go:167
- Consider expanding the comment to clarify that keys may use the '->' syntax for nested JSON updates. This will help maintainers quickly understand the expected input format.
// CompileJsonColumnsUpdate Compile the JSON columns for an update statement.
Contributor
Author
|
I will submit a separate PR to fix and add the external tests after the database driver repository PR is merged. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1092 +/- ##
=======================================
Coverage 71.09% 71.09%
=======================================
Files 183 183
Lines 12854 12854
=======================================
Hits 9138 9138
Misses 3345 3345
Partials 371 371 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hwbrzzl
approved these changes
Jun 25, 2025
1 task
This was referenced Jun 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📑 Description
Resolve goravel/goravel#712
Resolve goravel/goravel#713
When updating a JSON column, support use
->syntax to update the appropriate key in the JSON object.✅ Checks