Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def do_execute_no_params(self, cursor, statement, context=None):


# Alembic ALTER operation override
@compiles(ColumnNullable, "spanner")
@compiles(ColumnNullable, "spanner+spanner")
def visit_column_nullable(
element: "ColumnNullable", compiler: "SpannerDDLCompiler", **kw
) -> str:
Expand All @@ -1028,7 +1028,7 @@ def visit_column_nullable(


# Alembic ALTER operation override
@compiles(ColumnType, "spanner")
@compiles(ColumnType, "spanner+spanner")
def visit_column_type(
element: "ColumnType", compiler: "SpannerDDLCompiler", **kw
) -> str:
Expand Down
17 changes: 12 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ class = StreamHandler
'account',
'name',
existing_type=sa.String(70),
)"""
)
op.alter_column(
'account',
'description',
existing_type=sa.Unicode(200),
nullable=False,
)
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These strings are used in migration tests as a migration script.
Adding an operation, which was failing in the original issue, to make sure the case is tested.



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

# updating the upgrade-script code
with open(files[0], "r") as f:
script_code = f.read()
with open(files[0], "rb") as f:
script_code = f.read().decode()

script_code = script_code.replace(
"""def upgrade() -> None:\n pass""", UPGRADE_CODE
)
with open(files[0], "w") as f:
f.write(script_code)
with open(files[0], "wb") as f:
f.write(script_code.encode())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally I've got an error with rewriting a migration script by a program - some symbols were missing. Rewriting the file, using bytes, fixes the problem.


os.remove("test_migration/env.py")
shutil.copyfile("test_migration_env.py", "test_migration/env.py")
Expand Down