We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug
@dataclass class DbObject: id: Mapped[int] = mapped_column(primary_key=True) @mapper_registry.mapped_as_dataclass class IrsUser(DbObject): __tablename__ = "users" email: Mapped[str]
Result of alembic revision --autogenerate:
alembic revision --autogenerate
op.create_table('users', sa.Column('email', sa.String(), nullable=False), sa.Column('id', sa.Integer(), nullable=False), sa.PrimaryKeyConstraint('id') )
Expected behavior In most cases it should be in reverse order. Columns from base class should be added first, then columns from derived classes.
Versions: python 3.9 sqlalchemy 2.0.19 alembic 1.8,1
Have a nice day!
The text was updated successfully, but these errors were encountered:
Hi,
This behaviour comes from sqlalchemy, and it's unlikely to be changed, at least not in a minor version.
You can use sort_order to control how the columns are laid out in a table https://docs.sqlalchemy.org/en/20/orm/mapping_api.html#sqlalchemy.orm.mapped_column.params.sort_order
Sorry, something went wrong.
Many thanks, I did not know about sort order. This works:
@dataclass class DbObject: id: Mapped[int] = mapped_column(primary_key=True, sort_order=-99)
No branches or pull requests
Describe the bug
Result of
alembic revision --autogenerate
:Expected behavior
In most cases it should be in reverse order. Columns from base class should be added first, then columns from derived classes.
Versions:
python 3.9
sqlalchemy 2.0.19
alembic 1.8,1
Have a nice day!
The text was updated successfully, but these errors were encountered: