Skip to content

Skip virtual columns when generating cached fixture INSERTs#55

Merged
ngan merged 1 commit into
mainfrom
np-filter-virtual-columns
May 6, 2026
Merged

Skip virtual columns when generating cached fixture INSERTs#55
ngan merged 1 commit into
mainfrom
np-filter-virtual-columns

Conversation

@ngan
Copy link
Copy Markdown
Collaborator

@ngan ngan commented May 6, 2026

Summary

Filter virtual/generated columns from the cached INSERT statements built in ActiveRecordCoder#generate_statements. Without this, any model with a t.virtual column crashes mount with cannot INSERT into generated column.

Mirrors how Rails' build_fixture_sql filters them.

Repro

Adds a computed_widgets table to the dummy app with a stored generated column (name_upper) and a regression spec that:

  1. Creates two widgets in a fixture block
  2. Mounts the cached fixture
  3. Asserts both names round-tripped correctly and the generated column reflects the source values (UPPER(name))

Verified locally: without the fix, the spec fails with SQLite3::SQLException: cannot INSERT into generated column "name_upper".

Stack

Stacked on #54.

Test plan

  • New regression spec passes
  • All existing unit + integration specs pass on sqlite
  • CI green

🤖 Generated with Claude Code

@ngan ngan force-pushed the np-pool-with-connection branch from 7c5fcb5 to 4abd7b4 Compare May 6, 2026 20:10
@ngan ngan changed the base branch from np-pool-with-connection to main May 6, 2026 20:11
Models with generated/virtual columns reject INSERTs into those
columns ("cannot INSERT into generated column"). The coder was
including every column from model.column_names, so any model with a
t.virtual column would crash mount.

Filter columns by adapter capability + Column#virtual?, mirroring how
Rails' build_fixture_sql filters them in connection_adapters/abstract/
database_statements.rb.

Adds a computed_widgets table with a stored generated column to the
dummy app and a regression spec exercising the round-trip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ngan ngan marked this pull request as ready for review May 6, 2026 20:13
@ngan ngan force-pushed the np-filter-virtual-columns branch from 3d65e25 to a16df28 Compare May 6, 2026 20:13
@ngan ngan merged commit eecc0a3 into main May 6, 2026
8 checks passed
@ngan ngan deleted the np-filter-virtual-columns branch May 6, 2026 20:14
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.

1 participant