Skip to content

Commit 099ed03

Browse files
committed
Fix Db2ConnectionConfig.get_catalog() to return lowercase — align _default_catalog
The previous commit fixed get_current_catalog() in db2.py to return lowercase ('testdb'). But Db2ConnectionConfig.get_catalog() was still returning uppercase ('TESTDB'), which is passed as default_catalog= to the adapter constructor and stored in _default_catalog. The set_catalog decorator in shared.py:346 compares catalog_name (from the model definition, lowercased by the DuckDB-dialect config parser) against engine_adapter._default_catalog. With _default_catalog='TESTDB' and catalog_name='testdb', the raw == comparison fails and raises SQLMeshError. Fix: return catalog.lower() instead of catalog.upper() in get_catalog(). This makes _default_catalog='testdb', matching both get_current_catalog() and the catalog names produced by the DuckDB-dialect config parser. The set_catalog decorator strips the catalog from all DDL before sending it to Db2, so the case of this value never affects SQL sent to the engine.
1 parent 9d6d9e7 commit 099ed03

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎sqlmesh/core/config/connection.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,10 +2650,13 @@ def _engine_adapter(self) -> t.Type[EngineAdapter]:
26502650
)
26512651

26522652
def get_catalog(self) -> t.Optional[str]:
2653-
"""Db2 stores catalog names in uppercase; normalise here so the default_catalog
2654-
passed to the adapter matches what get_current_catalog() returns at runtime."""
2653+
"""Return the catalog name in lowercase so _default_catalog matches the value
2654+
returned by get_current_catalog() (which also returns lowercase) and the catalog
2655+
names produced by the DuckDB-dialect config parser (LOWERCASE normalisation).
2656+
The set_catalog decorator strips the catalog from all DDL before sending it to
2657+
Db2, so the case of this value never affects SQL sent to the engine."""
26552658
catalog = super().get_catalog()
2656-
return catalog.upper() if catalog else None
2659+
return catalog.lower() if catalog else None
26572660

26582661
@property
26592662
def _connection_factory(self) -> t.Callable:

0 commit comments

Comments
 (0)