Skip to content

Commit 6135887

Browse files
Extend the reflection canary with a TIME column
The canary test in test_reflect_column_types covered every standard SQLAlchemy type except Time. TIME columns round-trip through the storage path (covered in test_time_and_reflection), but the metadata path — what inspect(engine).get_columns() reports — had no guardrail against a future pysqlite change demoting the column to NullType. Add a Time column to the fixture and a bounded isinstance assertion that tolerates pysqlite's version-dependent TIME mapping (Time, String, or DateTime). The existing no-NullType sweep at the end of the test remains the primary contract; the union assertion just documents the concrete shape we observe today. Does not add a _DqliteTime colspec — reflection via the pysqlite parent is the deliberate current design. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2d28ceb commit 6135887

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

tests/integration/test_reflect_column_types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
String,
2323
Table,
2424
Text,
25+
Time,
2526
create_engine,
2627
inspect,
2728
types,
@@ -48,6 +49,7 @@ def engine(self, engine_url: str) -> Generator[Engine]:
4849
Column("ratio", Float),
4950
Column("created", DateTime),
5051
Column("birthday", Date),
52+
Column("start_time", Time),
5153
Column("flag", Boolean),
5254
)
5355
md.create_all(engine)
@@ -69,6 +71,11 @@ def test_reflects_standard_types(self, engine: Engine) -> None:
6971
assert isinstance(cols["ratio"]["type"], types.Float | types.Numeric)
7072
assert isinstance(cols["created"]["type"], types.DateTime)
7173
assert isinstance(cols["birthday"]["type"], types.Date)
74+
# TIME may reflect to Time, String, or DateTime depending on the
75+
# pysqlite version's ischema_names — the union accommodates the
76+
# documented uncertainty. The no-NullType assertion below still
77+
# applies, which is the main contract we care about.
78+
assert isinstance(cols["start_time"]["type"], types.Time | types.String | types.DateTime)
7279
assert isinstance(cols["flag"]["type"], BOOLEAN_LIKE)
7380

7481
# No column landed in NullType.

0 commit comments

Comments
 (0)