Skip to content

Conversation

@waltaskew
Copy link
Contributor

@waltaskew waltaskew commented Jul 30, 2025

Alembic expects get_column_default_string to be implemented in order to use it for ALTER TABLE.. ALTER COLUMN .. SET DEFAULT DDL. In our case, this means wrapping the default value in parentheses. We implement get_column_default_string and have it add parentheses for use in both CREATE TABLE and ALTER TABLE DDL.

Call path for alembic relying on get_column_default_string is here:

https://github.com/sqlalchemy/alembic/blob/cd4f404358f101b2b930013c609c074baca61468/alembic/ddl/base.py#L252 https://github.com/sqlalchemy/alembic/blob/cd4f404358f101b2b930013c609c074baca61468/alembic/ddl/base.py#L315

Fixes: #727

Alembic expects `get_column_default_string` to be implemented in order
to use it for  `ALTER TABLE.. ALTER COLUMN .. SET DEFAULT` DDL. In
our case, this means wrapping the default value in parentheses. We
implement `get_column_default_string` and have it add parentheses for
use in both `CREATE TABLE` and `ALTER TABLE` DDL.

Call path for alembic relying on `get_column_default_string` is here:

https://github.com/sqlalchemy/alembic/blob/cd4f404358f101b2b930013c609c074baca61468/alembic/ddl/base.py#L252
https://github.com/sqlalchemy/alembic/blob/cd4f404358f101b2b930013c609c074baca61468/alembic/ddl/base.py#L315
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. label Jul 30, 2025
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 18, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 18, 2025
@olavloite
Copy link
Contributor

Closing this, as all the changes in this PR were covered in #733

@olavloite olavloite closed this Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alembic Generates Incorrect DDL For ALTER COLUMN... SET DEFAULT ...

3 participants