Extracts parts of code from submodel_database.go#349
Merged
aaronzi merged 4 commits intoJun 9, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Submodel Repository PostgreSQL persistence layer by extracting previously monolithic logic from submodel_database.go into smaller, responsibility-focused files and by moving SQL construction into a dedicated queries package.
Changes:
- Split persistence logic into dedicated read/write/history/visibility/signing database files.
- Extracted SQL builders from persistence into
internal/submodelrepository/persistence/queries/submodel_database_queries.go. - Updated signing APIs and tests to use separate
GetSignedSubmodelandGetSignedSubmodelValueOnlymethods instead of avalueOnlyboolean parameter.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/submodelrepository/persistence/submodel_write_database.go | New file containing submodel create/patch/put/delete write logic and related helpers. |
| internal/submodelrepository/persistence/submodel_visibility.go | New file extracting ABAC visibility checks and formula enforcement helper. |
| internal/submodelrepository/persistence/submodel_signing.go | New file extracting JWS signing logic into separate full vs value-only methods. |
| internal/submodelrepository/persistence/submodel_read_database.go | New file containing submodel read/query/list logic and cursor helpers. |
| internal/submodelrepository/persistence/submodel_history_database.go | New file extracting submodel history append/snapshot helpers. |
| internal/submodelrepository/persistence/submodel_file_attachment_database.go | New file extracting File attachment CRUD + history-wrapped operations. |
| internal/submodelrepository/persistence/submodel_element_write_database.go | New file containing submodel element write operations and value-only update logic. |
| internal/submodelrepository/persistence/submodel_database.go | Reduced to core SubmodelDatabase struct and constructors after extraction. |
| internal/submodelrepository/persistence/submodel_database_signed_test.go | Updated tests to match new signing method split. |
| internal/submodelrepository/persistence/submodel_database_query_utils.go | Deleted legacy SQL builder utilities after moving builders to queries package. |
| internal/submodelrepository/persistence/queries/submodel_database_queries.go | New centralized SQL builder module for submodel persistence. |
| internal/submodelrepository/api/api_submodel_repository_api_service.go | Updated signing endpoints to call the new signing methods. |
Files not reviewed (1)
- internal/submodelrepository/api/api_submodel_repository_api_service.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
This PR refactors submodel_database.go