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
5 changes: 3 additions & 2 deletions google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,8 @@ def get_multi_columns(

sql = """
SELECT col.table_schema, col.table_name, col.column_name,
col.spanner_type, col.is_nullable, col.generation_expression
col.spanner_type, col.is_nullable, col.generation_expression,
col.column_default
FROM information_schema.columns as col
JOIN information_schema.tables AS t
USING (TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME)
Expand Down Expand Up @@ -1150,7 +1151,7 @@ def get_multi_columns(
"name": col[2],
"type": self._designate_type(col[3]),
"nullable": col[4] == "YES",
"default": None,
"default": col[6] if col[6] is not None else None,
}

if col[5] is not None:
Expand Down
7 changes: 5 additions & 2 deletions test/system/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)
from sqlalchemy.orm import Session, DeclarativeBase, Mapped, mapped_column
from sqlalchemy.types import REAL
from sqlalchemy.testing import eq_, is_true, is_not_none
from sqlalchemy.testing import eq_, is_true, is_not_none, is_none
from sqlalchemy.testing.plugin.plugin_base import fixtures


Expand All @@ -47,7 +47,7 @@ def define_tables(cls, metadata):
Column("number", Integer),
Column("name", String(20)),
Column("alternative_name", String(20)),
Column("prime", Boolean),
Column("prime", Boolean, server_default=text("FALSE")),
Column("ln", REAL),
PrimaryKeyConstraint("number"),
)
Expand Down Expand Up @@ -120,12 +120,15 @@ def test_reflect(self, connection):
eq_(5, len(table.columns))
eq_("number", table.columns[0].name)
eq_(BIGINT, type(table.columns[0].type))
is_none(table.columns[0].server_default)
eq_("name", table.columns[1].name)
eq_(String, type(table.columns[1].type))
eq_("alternative_name", table.columns[2].name)
eq_(String, type(table.columns[2].type))
eq_("prime", table.columns[3].name)
eq_(Boolean, type(table.columns[3].type))
is_not_none(table.columns[3].server_default)
eq_("FALSE", table.columns[3].server_default.arg.text)
eq_("ln", table.columns[4].name)
eq_(REAL, type(table.columns[4].type))
eq_(1, len(table.indexes))
Expand Down