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
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ def readme():
# https://github.com/googleapis/google-cloud-python/issues/10566
"google-auth>=1.25.0,<3.0.0dev", # Work around pip wack.
"google-cloud-bigquery>=2.25.2,<3.0.0dev",
"sqlalchemy>=1.2.0,<1.5.0dev",
# Temporarily set maximimum sqlalchemy to a known-working version while
# we debug failing compliance tests. See:
# https://github.com/googleapis/python-bigquery-sqlalchemy/issues/386
# and
# https://github.com/googleapis/python-bigquery-sqlalchemy/issues/385
"sqlalchemy>=1.2.0,<=1.4.25",
"future",
],
extras_require=extras,
Expand Down
40 changes: 18 additions & 22 deletions tests/system/test_alembic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from sqlalchemy import Column, DateTime, Integer, String

import google.api_core.exceptions
from google.cloud.bigquery import SchemaField

alembic = pytest.importorskip("alembic")

Expand All @@ -43,10 +44,7 @@ def get_table(table_name, data="table"):
if data == "table":
return table
elif data == "schema":
return [
repr(s).replace(", (), None)", ")").replace(", None)", ")")
for s in table.schema
]
return table.schema
else:
raise ValueError(data)
except google.api_core.exceptions.NotFound:
Expand Down Expand Up @@ -78,9 +76,9 @@ def test_alembic_scenario(alembic_table):
Column("description", String(200)),
)
assert alembic_table("account", "schema") == [
"SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())",
"SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())",
"SchemaField('description', 'STRING(200)', 'NULLABLE', None, (), ())",
SchemaField("id", "INTEGER", "REQUIRED"),
SchemaField("name", "STRING(50)", "REQUIRED", description="The name"),
SchemaField("description", "STRING(200)"),
]

op.bulk_insert(
Expand All @@ -103,11 +101,10 @@ def test_alembic_scenario(alembic_table):
)

assert alembic_table("account", "schema") == [
"SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())",
"SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())",
"SchemaField('description', 'STRING(200)', 'NULLABLE', None, (), ())",
"SchemaField('last_transaction_date', 'DATETIME', 'NULLABLE', 'when updated'"
", (), ())",
SchemaField("id", "INTEGER", "REQUIRED"),
SchemaField("name", "STRING(50)", "REQUIRED", description="The name"),
SchemaField("description", "STRING(200)"),
SchemaField("last_transaction_date", "DATETIME", description="when updated"),
]

op.create_table(
Expand All @@ -123,8 +120,8 @@ def test_alembic_scenario(alembic_table):

op.drop_column("account_w_comment", "description")
assert alembic_table("account_w_comment", "schema") == [
"SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())",
"SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())",
SchemaField("id", "INTEGER", "REQUIRED"),
SchemaField("name", "STRING(50)", "REQUIRED", description="The name"),
]

op.drop_table("account_w_comment")
Expand All @@ -133,11 +130,10 @@ def test_alembic_scenario(alembic_table):
op.rename_table("account", "accounts")
assert alembic_table("account") is None
assert alembic_table("accounts", "schema") == [
"SchemaField('id', 'INTEGER', 'REQUIRED', None, (), ())",
"SchemaField('name', 'STRING(50)', 'REQUIRED', 'The name', (), ())",
"SchemaField('description', 'STRING(200)', 'NULLABLE', None, (), ())",
"SchemaField('last_transaction_date', 'DATETIME', 'NULLABLE', 'when updated'"
", (), ())",
SchemaField("id", "INTEGER", "REQUIRED"),
SchemaField("name", "STRING(50)", "REQUIRED", description="The name"),
SchemaField("description", "STRING(200)"),
SchemaField("last_transaction_date", "DATETIME", description="when updated"),
]
op.drop_table("accounts")
assert alembic_table("accounts") is None
Expand All @@ -157,9 +153,9 @@ def test_alembic_scenario(alembic_table):
# nullable:
op.alter_column("transactions", "amount", True)
assert alembic_table("transactions", "schema") == [
"SchemaField('account', 'INTEGER', 'REQUIRED', None, (), ())",
"SchemaField('transaction_time', 'DATETIME', 'REQUIRED', None, (), ())",
"SchemaField('amount', 'NUMERIC(11, 2)', 'NULLABLE', None, (), ())",
SchemaField("account", "INTEGER", "REQUIRED"),
SchemaField("transaction_time", "DATETIME", "REQUIRED"),
SchemaField("amount", "NUMERIC(11, 2)"),
]

op.create_table_comment("transactions", "Transaction log")
Expand Down