Skip to content

Commit f9e8ebe

Browse files
authored
fix: update dialect name for ALTER operation overrides (#234)
1 parent 8bab5fb commit f9e8ebe

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ def do_execute_no_params(self, cursor, statement, context=None):
10151015

10161016

10171017
# Alembic ALTER operation override
1018-
@compiles(ColumnNullable, "spanner")
1018+
@compiles(ColumnNullable, "spanner+spanner")
10191019
def visit_column_nullable(
10201020
element: "ColumnNullable", compiler: "SpannerDDLCompiler", **kw
10211021
) -> str:
@@ -1028,7 +1028,7 @@ def visit_column_nullable(
10281028

10291029

10301030
# Alembic ALTER operation override
1031-
@compiles(ColumnType, "spanner")
1031+
@compiles(ColumnType, "spanner+spanner")
10321032
def visit_column_type(
10331033
element: "ColumnType", compiler: "SpannerDDLCompiler", **kw
10341034
) -> str:

noxfile.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ class = StreamHandler
6565
'account',
6666
'name',
6767
existing_type=sa.String(70),
68-
)"""
68+
)
69+
op.alter_column(
70+
'account',
71+
'description',
72+
existing_type=sa.Unicode(200),
73+
nullable=False,
74+
)
75+
"""
6976

7077

7178
BLACK_VERSION = "black==22.3.0"
@@ -254,14 +261,14 @@ def migration_test(session):
254261
files = glob.glob("test_migration/versions/*.py")
255262

256263
# updating the upgrade-script code
257-
with open(files[0], "r") as f:
258-
script_code = f.read()
264+
with open(files[0], "rb") as f:
265+
script_code = f.read().decode()
259266

260267
script_code = script_code.replace(
261268
"""def upgrade() -> None:\n pass""", UPGRADE_CODE
262269
)
263-
with open(files[0], "w") as f:
264-
f.write(script_code)
270+
with open(files[0], "wb") as f:
271+
f.write(script_code.encode())
265272

266273
os.remove("test_migration/env.py")
267274
shutil.copyfile("test_migration_env.py", "test_migration/env.py")

0 commit comments

Comments
 (0)