Skip to content

Rename a column named registry, like metadata already was - #491

Merged
sheinbergon merged 2 commits into
agronholm:masterfrom
abhishekcpp007:rename-registry-column
Nov 18, 2026
Merged

sheinbergon merged 2 commits into
agronholm:masterfrom
abhishekcpp007:rename-registry-column

Conversation

@abhishekcpp007

Copy link
Copy Markdown
Contributor

SQLAlchemy reserves both metadata and registry on a declarative class and warns about either one (orm/decl_base.py, the k == "registry" or ... branch). find_free_name only renames metadata, so a table with a registry column generates code that warns as soon as it is imported:

SAWarning: Attribute name 'registry' should be left reserved for the Declarative
class registry when using a Declarative class.

Reproduced with sqlacodegen 4.0.4 against CREATE TABLE collide (id INTEGER PRIMARY KEY, metadata TEXT, registry TEXT) on SQLite: the metadata column came out as metadata_, the registry one came out as registry.

One word change plus a test that mirrors test_metadata_column. Verified in Docker on 3.12: master 12 failed 151 passed, branch 12 failed 152 passed, and the twelve failures are the same postgres ones on both.

Disclaimer: I used an LLM while working on this.

@sheinbergon

Copy link
Copy Markdown
Collaborator

@abhishekcpp007, please bind dependency versions with <2.1 so we can merge this PR

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 97.853% (+0.004%) from 97.849% — abhishekcpp007:rename-registry-column into agronholm:master

@sheinbergon
sheinbergon merged commit 9757bc2 into agronholm:master Nov 18, 2026
8 checks passed
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.

3 participants