Skip to content

Conversation

kgpayne
Copy link

@kgpayne kgpayne commented Aug 15, 2025

Column.table can be None, and when that happens it results in:

AttributeError: 'NoneType' object has no attribute '_autoincrement_column'

We use SQLAlchemy to compose dialect-correct DDL statements like:

import sqlalchemy as sa
from sqlalchemy.sql import ddl

create_column_clause = ddl.CreateColumn(
    sa.Column(
       column_name,
        column_type,
    ),
)
compiled = create_column_clause.compile(self._engine).string
return sa.DDL(
    "ALTER TABLE %(table_name)s ADD COLUMN %(create_column_clause)s",
    {
        "table_name": table_name,
        "create_column_clause": compiled,
    },
)

This is why Column.table is None.

Signed-off-by: Ken Payne <[email protected]>
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