Skip to content

Commit 286305f

Browse files
authored
Fix: table_naming_convention not passed in all cases (#5062)
1 parent 036b75e commit 286305f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

sqlmesh/core/snapshot/definition.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ def data_version(self) -> SnapshotDataVersion:
527527
change_category=self.change_category,
528528
physical_schema=self.physical_schema,
529529
dev_table_suffix=self.dev_table_suffix,
530+
table_naming_convention=self.table_naming_convention,
530531
)
531532

532533
@property

tests/core/test_snapshot.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,26 @@ def test_table_name_naming_convention_hash_md5(make_snapshot: t.Callable[..., Sn
12501250
assert snapshot.table_name(is_deployable=False) == f"sqlmesh__foo.sqlmesh_md5__{hash_dev}__dev"
12511251

12521252

1253+
def test_table_naming_convention_passed_around_correctly(make_snapshot: t.Callable[..., Snapshot]):
1254+
snapshot = make_snapshot(
1255+
SqlModel(name='"foo"."bar"."baz"', query=parse_one("select 1")),
1256+
table_naming_convention=TableNamingConvention.HASH_MD5,
1257+
)
1258+
snapshot.categorize_as(SnapshotChangeCategory.BREAKING)
1259+
1260+
assert snapshot.table_naming_convention == TableNamingConvention.HASH_MD5
1261+
assert snapshot.data_version.table_naming_convention == TableNamingConvention.HASH_MD5
1262+
assert snapshot.table_info.table_naming_convention == TableNamingConvention.HASH_MD5
1263+
assert (
1264+
snapshot.table_info.data_version.table_naming_convention == TableNamingConvention.HASH_MD5
1265+
)
1266+
assert snapshot.table_info.table_info.table_naming_convention == TableNamingConvention.HASH_MD5
1267+
assert (
1268+
snapshot.table_info.table_info.data_version.table_naming_convention
1269+
== TableNamingConvention.HASH_MD5
1270+
)
1271+
1272+
12531273
def test_table_name_view(make_snapshot: t.Callable):
12541274
# Mimic a direct breaking change.
12551275
snapshot = make_snapshot(SqlModel(name="name", query=parse_one("select 1"), kind="VIEW"))

0 commit comments

Comments
 (0)