Skip to content

Add portable duplicate-row deletion and fluent API - #198

Merged
jogibear9988 merged 2 commits into
masterfrom
codex/kcc-delete-duplicates
Sep 24, 2026
Merged

jogibear9988 merged 2 commits into
masterfrom
codex/kcc-delete-duplicates

Conversation

@jogibear9988

Copy link
Copy Markdown
Member

Consumers currently repeat provider-specific SQL to remove duplicate composite keys before schema migrations. This adds DeleteDuplicateRows(table, keyColumns, DuplicateRowRetention.Any, nulls) and Delete.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; ExcludeNullKeys leaves 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:

  • Full Unit/SQLite selection: 1,189 passed (22 new cases).
  • Configured SQL Server, PostgreSQL and Oracle: 12 new live cases passed, exercising both APIs and NULL policies.
  • Documentation: 108 C# samples compiled; 8 Classic/Fluent SQLite parity checks passed.
  • Release package build passed.

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.

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.
Copilot AI lite review requested due to automatic review settings September 24, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Base automatically changed from codex/kcc-schema-api to master September 24, 2026 13:37
@jogibear9988
jogibear9988 merged commit f3a1cd0 into master Sep 24, 2026
13 checks passed
@jogibear9988
jogibear9988 deleted the codex/kcc-delete-duplicates branch September 24, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants