Skip to content

Add table_of for a typed mapped table - #64

Open
nicoloesch wants to merge 1 commit into
mainfrom
58-typed-table-accessor
Open

nicoloesch wants to merge 1 commit into
mainfrom
58-typed-table-accessor

Conversation

@nicoloesch

Copy link
Copy Markdown
Collaborator

Summary

  • Adds table_of(model), exported from oa_configurator. It returns the sqlalchemy.Table a mapped class is mapped to, so .c, .schema and .primary_key need no cast or ignore.
  • Raises TypeError naming the class when it is unmapped or mapped to something other than a table, such as a join.
  • Returns the same __table__ object, so mapper, schema and schema_translate_map behaviour is unchanged.
  • SchemaRegistry.table() uses it in place of an assert, which python -O removes.
  • Tests cover a mapped class, SchemaRegistry.table(), a class mapped to a join and an unmapped class.

Checklist

  • Applied exactly one label (breaking, feature, fix, dependencies, or chore)
  • Tests pass locally (uv run pytest -q)
  • Lint passes (uv run ruff check .)

@nicoloesch nicoloesch added the feature New backwards-compatible functionality. MINOR: x.y+1.z label Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New backwards-compatible functionality. MINOR: x.y+1.z

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a typed table accessor for ORM classes

1 participant