Skip to content

Commit

Permalink
fix: Add existing_nullable usage to visit_column_type (#329)
Browse files Browse the repository at this point in the history
* fix: Add `existing_nullable` usage to `visit_column_type`

Without this, altering operations (e.g. change column length) can cause nullability change of the column.
It then causes error if this column is a part of index:
"400 Changing NOT NULL constraints on column column_name is not allowed because it affects index index_name"

* fix: add missing placeholder

---------

Co-authored-by: Knut Olav Løite <[email protected]>
  • Loading branch information
minev-dev and olavloite authored Nov 4, 2024
1 parent 013bd83 commit 273f03b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,8 +1564,9 @@ def visit_column_nullable(
def visit_column_type(
element: "ColumnType", compiler: "SpannerDDLCompiler", **kw
) -> str:
return "%s %s %s" % (
return "%s %s %s %s" % (
alter_table(compiler, element.table_name, element.schema),
alter_column(compiler, element.column_name),
"%s" % format_type(compiler, element.type_),
"" if element.existing_nullable else "NOT NULL",
)

0 comments on commit 273f03b

Please sign in to comment.