This repository was archived by the owner on Sep 1, 2026. It is now read-only.
fix: make pre_hash optional and add row_id to UpsertDatatabaseRow - #1614
Open
davideconte wants to merge 1 commit into
Open
fix: make pre_hash optional and add row_id to UpsertDatatabaseRow#1614davideconte wants to merge 1 commit into
davideconte wants to merge 1 commit into
Conversation
- pre_hash is now Option<String>: if None, a random UUID is generated - New optional row_id field: if provided, use it directly as the row UUID - This enables UPDATE operations when you know the row ID (e.g. from list) - Backward compatible: existing clients that always pass pre_hash still work
Reviewer's GuideMakes the UpsertDatatabaseRow DTO and handler more flexible by making pre_hash optional, introducing an explicit row_id override, and updating row ID derivation logic to support both existing dedup semantics and direct UUID-based addressing. Class diagram for updated UpsertDatatabaseRow DTOclassDiagram
class UpsertDatatabaseRow {
+Option<String> pre_hash
+Option<String> row_id
+HashMap<String, serde_json::Value> cells
+Option<String> document
}
Flow diagram for updated row_id resolution in put_database_row_handlerflowchart TD
A[put_database_row_handler receives UpsertDatatabaseRow] --> B{row_id provided?}
B -- Yes --> C[Parse row_id as UUID]
C --> H[Call upsert_database_row with row_id UUID]
B -- No --> D{pre_hash provided?}
D -- Yes --> E[Compute SHA256 of workspace_id + db_id + pre_hash]
E --> F[Take first 16 bytes of hash as UUID]
F --> H
D -- No --> G[Generate new random UUID]
G --> H[Call upsert_database_row with row_id UUID]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The precedence behavior when both
row_idandpre_hashare provided is implicit in the handler (prefersrow_id), but not documented in the DTO comments; consider either explicitly documenting this precedence or rejecting requests that set both to avoid ambiguous usage. - You parse
row_idfrom aStringin the handler; if this type is only used internally (not a public API contract), you might simplify by makingrow_id: Option<Uuid>onUpsertDatatabaseRowto centralize validation and reduce parsing logic at the boundary.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The precedence behavior when both `row_id` and `pre_hash` are provided is implicit in the handler (prefers `row_id`), but not documented in the DTO comments; consider either explicitly documenting this precedence or rejecting requests that set both to avoid ambiguous usage.
- You parse `row_id` from a `String` in the handler; if this type is only used internally (not a public API contract), you might simplify by making `row_id: Option<Uuid>` on `UpsertDatatabaseRow` to centralize validation and reduce parsing logic at the boundary.Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
The endpoint currently requires a field which is used to derive the row's UUID via SHA256. This makes it impossible to update existing rows because:
This PR fixes the issue by:
Changes
libs/shared-entity/src/dto/workspace_dto.rs
src/api/workspace.rs ( handler)
This allows both creating new rows without a , and updating existing rows by passing the known .
Testing
Summary by Sourcery
Make database row upserts support optional pre-hash values and direct row ID specification to enable both new row creation and updates of existing rows.
New Features:
Enhancements: