Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: raise Unimplemented error when creating temporary tables #159

Merged
merged 8 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Data types table mapping SQLAlchemy types to Cloud Spanner types:
### Other limitations
- WITH RECURSIVE statement is not supported.
- Named schemas are not supported.
- Temporary tables are not supported, real tables are used instead.
- Temporary tables are not supported.
- Numeric type dimensions (scale and precision) are constant. See the [docs](https://cloud.google.com/spanner/docs/data-types#numeric_types).

## Best practices
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/sqlalchemy_spanner/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

@temp_table_keyword_args.for_db("spanner")
def _spanner_temp_table_keyword_args(cfg, eng):
return {}
return {"prefixes": ["TEMPORARY"]}
5 changes: 5 additions & 0 deletions google/cloud/sqlalchemy_spanner/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def isolation_level(self):
def sequences(self):
return exclusions.closed()

@property
def temporary_tables(self):
"""Target database supports temporary tables."""
return exclusions.closed()
IlyaFaer marked this conversation as resolved.
Show resolved Hide resolved

def get_order_by_collation(self, _):
"""Get the default collation name.

Expand Down
3 changes: 3 additions & 0 deletions google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ def post_create_table(self, table):
cols = [col.name for col in table.primary_key.columns]
post_cmds = " PRIMARY KEY ({})".format(", ".join(cols))

if table._prefixes == ["TEMPORARY"]:
larkee marked this conversation as resolved.
Show resolved Hide resolved
raise NotImplementedError("Temporary tables are not supported.")

if table.kwargs.get("spanner_interleave_in"):
post_cmds += ",\nINTERLEAVE IN PARENT {}".format(
table.kwargs["spanner_interleave_in"]
Expand Down
3 changes: 0 additions & 3 deletions test/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from sqlalchemy.testing import provide_metadata, emits_warning
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_true
from sqlalchemy.testing.provision import temp_table_keyword_args
from sqlalchemy.testing.schema import Column
from sqlalchemy.testing.schema import Table
from sqlalchemy import literal_column
Expand Down Expand Up @@ -676,7 +675,6 @@ def define_temp_tables(cls, metadata):
creating unique constraints. Overriding the test to replace
constraints with indexes in testing data.
"""
kw = temp_table_keyword_args(config, config.db)
user_tmp = Table(
"user_tmp",
metadata,
Expand All @@ -685,7 +683,6 @@ def define_temp_tables(cls, metadata):
Column("foo", sqlalchemy.INT),
sqlalchemy.Index("user_tmp_uq", "name", unique=True),
sqlalchemy.Index("user_tmp_ix", "foo"),
**kw,
)
if (
testing.requires.view_reflection.enabled
Expand Down