Fix BulkInsert composite PK handling for partitioned tables#4222
Merged
jeremydmiller merged 1 commit intomasterfrom Mar 31, 2026
Merged
Fix BulkInsert composite PK handling for partitioned tables#4222jeremydmiller merged 1 commit intomasterfrom
jeremydmiller merged 1 commit intomasterfrom
Conversation
BulkLoaderBuilder.CopyNewDocumentsFromTempTable() and OverwriteDuplicatesFromTempTable() hardcoded 'id' (+ tenant_id) in their join expressions. For partitioned tables where partition columns are part of the composite PK (e.g., (id, date)), this caused: - IgnoreDuplicates: rows with same id but different partition key treated as duplicates and skipped - OverwriteExisting: ambiguous UPDATE matches followed by duplicate key violations on the INSERT Fix: build join expressions from table.PrimaryKeyColumns instead of hardcoding column names. Also exclude all PK columns from the UPDATE SET clause (not just 'id'). Closes #4219 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hello, Thank you so much for the quick fix! We really appreciate your responsiveness. We're currently on Marten 7.29.0 and upgrading to 8.x would require significant work on our side (dependency updates, testing, etc.). Thanks again for building and maintaining Marten ! |
Member
Author
|
@Gafs63 That's a big ask. Typically we don't do that for old releases outside of JasperFx support customers. I'd take the pull request to 7.* if you want to try to retrofit that yourself. |
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
BulkInsertAsyncwithIgnoreDuplicatesandOverwriteExistingmodes to use the full composite primary key when joining against partitioned tablesBulkLoaderBuilderhardcodedid(+tenant_idfor conjoined) in join expressions, ignoring partition columns that are part of the composite PKtable.PrimaryKeyColumns, matching how the generatedmt_upsert_*functions already workCloses #4219
Test plan
🤖 Generated with Claude Code