Fix mt_update and mt_upsert WHERE clauses for partitioned tables#4236
Merged
jeremydmiller merged 1 commit intomasterfrom Apr 6, 2026
Merged
Fix mt_update and mt_upsert WHERE clauses for partitioned tables#4236jeremydmiller merged 1 commit intomasterfrom
jeremydmiller merged 1 commit intomasterfrom
Conversation
When tables have partition columns in their composite PK (e.g., id + date), the generated mt_update_* function's WHERE clause only used "id = docId", ignoring the partition column. This caused updates to target all rows with the same id regardless of partition key, leading to duplicate key errors. Fix: build _andPartitionWhereClause from partition columns and their corresponding function arguments, then append to all WHERE clauses in both UpdateFunction and UpsertFunction (UPDATE, SELECT mt_version). The UpsertFunction's ON CONFLICT clause was already correct (uses _primaryKeyFields), but its SELECT statements had the same issue. Closes #4223 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 7, 2026
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.
Summary
mt_update_*function to include partition columns in WHERE clause alongsideid = docIdSELECT mt_versionstatements in bothmt_update_*andmt_upsert_*to include partition columnsCloses #4223
What Changed
UpsertFunction.cs— build_andPartitionWhereClausefrom partition columns, append to all WHERE/SELECT clausesUpdateFunction.cs— append_andPartitionWhereClauseto UPDATE WHERE and SELECT WHERE clausesExample
For a table with PK
(id, date):Test plan
🤖 Generated with Claude Code