Skip to content

Generate model-aware fixtures for configured tables - #113

Open
nertzy wants to merge 1 commit into
with-model-test-unit-harnessfrom
resolve-configured-table-name-rdy
Open

Generate model-aware fixtures for configured tables#113
nertzy wants to merge 1 commit into
with-model-test-unit-harnessfrom
resolve-configured-table-name-rdy

Conversation

@nertzy

@nertzy nertzy commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Fixture generation infers model constants from conventional table names. Models with a configured table_name can therefore fall back to raw SQL, bypassing model-backed serialization. Generated fixture filenames also do not necessarily tell Rails which model to use when loading them.

Extract model selection into ModelResolver, retaining conventional autoloading while matching loaded models by their actual table and connection pool. Collapse STI descendants to their eligible root, retain SQL fallback for tables without a usable model, and raise on ambiguous independent models before replacing fixture YAML.

Every model-backed fixture file now declares its resolved class through Rails’ native _fixture.model_class metadata, including conventionally named models. Rails can consume the generated files without a separate class map. Empty-file behavior still depends on actual rows, and the reserved _fixture record label is rejected rather than silently overwritten.

The README describes Rails’ existing mapping precedence, native loading transformations, and raw-table limitations. This adds no eager-loading requirement, public mapping API, or custom mapping cache.

@nertzy nertzy changed the title resolve configured table name rdy Resolve models by configured table name Sep 5, 2026
@nertzy
nertzy force-pushed the resolve-configured-table-name-rdy branch from 3282a12 to 4f487c8 Compare September 5, 2026 01:30
Document native metadata, model eligibility, and generated configuration output.
@nertzy
nertzy force-pushed the resolve-configured-table-name-rdy branch from 4f487c8 to 83554cd Compare September 7, 2026 00:55
@nertzy nertzy changed the title Resolve models by configured table name Generate model-aware fixtures for configured tables Sep 7, 2026
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