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
2 changes: 1 addition & 1 deletion google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def post_create_table(self, table):
return post_cmds

def visit_create_index(
self, create, include_schema=False, include_table_schema=True, **kw
self, create, include_schema=True, include_table_schema=True, **kw
):
text = super().visit_create_index(
create, include_schema, include_table_schema, **kw
Expand Down
42 changes: 42 additions & 0 deletions test/mockserver_tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
MetaData,
Table,
Column,
Index,
Integer,
String,
func,
Expand Down Expand Up @@ -134,6 +135,47 @@ def test_create_table(self):
requests[0].statements[0],
)

def test_create_table_in_schema(self):
add_result(
"""SELECT true
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA="schema" AND TABLE_NAME="users"
LIMIT 1
""",
ResultSet(),
)
engine = create_engine(
"spanner:///projects/p/instances/i/databases/d",
connect_args={"client": self.client, "pool": FixedSizePool(size=10)},
)
metadata = MetaData()
Table(
"users",
metadata,
Column("user_id", Integer, primary_key=True),
Column("user_name", String(16), nullable=False),
Index("ix_users_user_id", "user_id"),
schema="schema",
)
metadata.create_all(engine)
requests = self.database_admin_service.requests
eq_(1, len(requests))
is_instance_of(requests[0], UpdateDatabaseDdlRequest)
eq_(2, len(requests[0].statements))

eq_(
"CREATE TABLE schema.users (\n"
"\tuser_id INT64 NOT NULL "
"GENERATED BY DEFAULT AS IDENTITY (BIT_REVERSED_POSITIVE), \n"
"\tuser_name STRING(16) NOT NULL\n"
") PRIMARY KEY (user_id)",
requests[0].statements[0],
)
eq_(
"CREATE INDEX schema.ix_users_user_id ON schema.users (user_id)",
requests[0].statements[1],
)

def test_create_multiple_tables(self):
for i in range(2):
add_result(
Expand Down