Skip to content

feat: add ignore_columns to exclude columns from reconciliation#35

Merged
mikkeldamsgaard merged 1 commit intomainfrom
feat/ignore-columns
Mar 12, 2026
Merged

feat: add ignore_columns to exclude columns from reconciliation#35
mikkeldamsgaard merged 1 commit intomainfrom
feat/ignore-columns

Conversation

@mikkeldamsgaard
Copy link
Contributor

Summary

  • Adds ignore_columns option to tables in reconcile mode
  • Ignored columns are included in the initial INSERT but excluded from change detection, UPDATE statements, and content hash computation
  • Use case: timestamps, random tokens, or values managed by database triggers that should not be overwritten during reconciliation
  • Validation rejects overlap between ignore_columns and unique_key, and rejects empty entries

Example

tables:
  - table: users
    unique_key: [email]
    ignore_columns: [created_at, api_token]
    rows:
      - email: alice@example.com
        name: Alice
        created_at: "2026-01-01"
        api_token: "$env:ALICE_TOKEN"

Test plan

  • Schema validation: rejects overlap with unique_key
  • Schema validation: rejects empty entries
  • Schema validation: accepts valid ignore_columns
  • Hash: ignored columns don't affect content hash
  • Executor: ignored columns not compared (no spurious updates)
  • Executor: ignored columns still inserted on new rows
  • Executor: non-ignored columns updated while ignored columns preserved
  • All 191 tests pass, clippy clean, fmt clean

🤖 Generated with Claude Code

Columns listed in ignore_columns are included in the initial INSERT
but excluded from change detection, UPDATE statements, and content
hash computation. Useful for timestamps, tokens, or values managed
by database triggers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 12, 2026 11:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an ignore_columns option for reconcile-mode table specs so certain columns are inserted initially but excluded from reconciliation change detection, UPDATE statements, and content-hash based skip logic.

Changes:

  • Extend seed schema with ignore_columns and add validation (no empty entries, no overlap with unique_key).
  • Update reconciliation executor to exclude ignored columns from row comparison and UPDATE column sets.
  • Update seed-set content hash computation and docs/tests to reflect ignore behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/seed/schema.rs Adds ignore_columns to the schema and validates it for reconcile mode; adds schema validation tests.
src/seed/hash.rs Excludes ignored columns from content hash computation; adds a hash test for ignored columns.
src/seed/executor.rs Excludes ignored columns from tracked row comparison and UPDATE generation; adds reconciliation tests around ignored columns.
docs/seeding.md Documents ignore_columns behavior and constraints in reconcile mode.
CHANGELOG.md Notes the new ignore_columns feature in Unreleased.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +46 to +50
// Ignored columns don't affect the hash — changes to them
// won't trigger reconciliation.
if ts.ignore_columns.contains(key) {
continue;
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

compute_seed_set_hash excludes values for ignored columns, but it does not incorporate the ignore_columns configuration itself into the hash. This means changing ignore_columns (e.g., adding/removing a column) may not change the content hash, causing reconcile mode to incorrectly skip the seed set even though reconciliation semantics and tracked row encoding have changed. Include a deterministic representation of ts.ignore_columns (e.g., JSON of the list, ideally normalized/sorted) in the hash similarly to unique_key so config changes trigger reconciliation.

Copilot uses AI. Check for mistakes.
Comment on lines +261 to +274
if ts.ignore_columns.iter().any(|c| c.trim().is_empty()) {
return Err(format!(
"table '{}' in seed_set '{}' has empty or whitespace-only entries in ignore_columns",
ts.table, ss.name
));
}
for ic in &ts.ignore_columns {
if ts.unique_key.contains(ic) {
return Err(format!(
"table '{}' in seed_set '{}': column '{}' cannot be in both unique_key and ignore_columns",
ts.table, ss.name, ic
));
}
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

The ignore_columns validation is currently only executed when ss.is_reconcile() (i.e., mode: reconcile in the spec). However --reconcile-all can force reconciliation for mode: once seed sets, bypassing these new checks (empty/whitespace entries, overlap with unique_key). Consider validating ignore_columns regardless of seed set mode, or adding equivalent validation in the executor’s reconcile-all guard, so invalid configs are consistently rejected whenever reconciliation can run.

Copilot uses AI. Check for mistakes.
@mikkeldamsgaard mikkeldamsgaard merged commit 21727d5 into main Mar 12, 2026
10 checks passed
@mikkeldamsgaard mikkeldamsgaard deleted the feat/ignore-columns branch March 12, 2026 12:02
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