Add portable duplicate-row deletion and fluent API - #198
Merged
Merged
Conversation
Consumers currently repeat physical-row SQL for SQLite, PostgreSQL, Oracle and SQL Server. Provide explicit arbitrary-survivor semantics through DeleteDuplicateRows and the fluent Delete.DuplicateRows builder, including equal/excluded NULL keys and affected-row counts. Validate keys and unsupported row identities before deletion; preserve transaction ownership and reject automatic reversal and metadata-free SQL preview. Cover both SQLite drivers, rollback, composite keys, quoting, rowid shadowing, unsupported providers and direct/fluent execution on all three server databases. Unit/SQLite: 1189 passed; live SQL Server/PostgreSQL/Oracle: 12 passed; 108 documentation examples compiled.
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.
Consumers currently repeat provider-specific SQL to remove duplicate composite keys before schema migrations. This adds
DeleteDuplicateRows(table, keyColumns, DuplicateRowRetention.Any, nulls)andDelete.DuplicateRows().FromTable(table).ByColumns(...).KeepAny(nulls)so migrations can explicitly keep one arbitrary row per key.Supported providers: SQLite ordinary rowid tables (both drivers), PostgreSQL, Oracle ROWID tables and SQL Server. NULL keys compare equal by default;
ExcludeNullKeysleaves rows containing NULL keys untouched. The direct API returns the database-reported affected count. Validation rejects invalid keys, unsupported providers and inaccessible SQLite physical row identities. PostgreSQL uses tableoid plus ctid to distinguish partition rows.One DELETE executes in the caller's transaction. Schema, triggers and foreign-key semantics remain with the database; this does not prevent future/concurrent duplicates. Automatic reversal and metadata-free SQL preview explicitly reject this operation. Documentation includes both API forms.
Validation:
This branch includes the schema API work from #197. If that PR is still open, this PR is stacked on its branch; retarget to master after #197 merges.