SQL 检查认时间列时带上 ENUM 的取值列表:PG 里类型名带 DATE 的枚举列,剖析不认是日期列、SQL 检查却认,两边对不上

This commit is contained in:
ThearchyHelios
2026-10-16 12:53:07 +08:00
parent 3f5cf79b26
commit 736b031282
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -555,3 +555,15 @@ async def test_checker_builds_relation_graph_lazily_and_reuses_it(cache, monkeyp
checker.check(FANOUT[0])
checker.check(FANOUT[1])
assert calls == [1]
def test_a_postgres_enum_whose_type_name_says_date_is_not_a_time_column():
"""PG 的枚举编译出来就是类型名本身(update_date_kind 里也有 DATE):探查记下了 enum_values 的列,SQL 检查和剖析一样
不把它当时间列。以前 SQL 检查认时间列时没把取值列表传进去,剖析不认、SQL 检查却认,两边对不上。"""
from app.data.sqlcheck import _Table
meta = {"columns": [{"name": "kind", "type": "update_date_kind", "enum_values": ["a", "b"]},
{"name": "paid_on", "type": "DATE"}]}
table = _Table(alias="t", name="t", meta=meta, notes={}, order=0)
assert not table.temporal("kind")
assert table.temporal("paid_on")