Skip to content

Commit 94e7978

Browse files
Revert "fix(mssql): update driver selection logic to allow enforcing pyodbc in Fabric"
This reverts commit 4412fc9.
1 parent cd4aa95 commit 94e7978

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

sqlmesh/core/config/connection.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,14 +1529,7 @@ def _mssql_engine_import_validator(cls, data: t.Any) -> t.Any:
15291529
if not isinstance(data, dict):
15301530
return data
15311531

1532-
# Get the default driver for this specific class
1533-
default_driver = "pymssql"
1534-
if hasattr(cls, "model_fields") and "driver" in cls.model_fields:
1535-
field_info = cls.model_fields["driver"]
1536-
if hasattr(field_info, "default") and field_info.default is not None:
1537-
default_driver = field_info.default
1538-
1539-
driver = data.get("driver", default_driver)
1532+
driver = data.get("driver", "pymssql")
15401533

15411534
# Define the mapping of driver to import module and extra name
15421535
driver_configs = {"pymssql": ("pymssql", "mssql"), "pyodbc": ("pyodbc", "mssql-odbc")}

tests/core/test_connection_config.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,50 +1770,3 @@ def test_fabric_pyodbc_connection_string_generation():
17701770

17711771
# Check autocommit parameter, should default to True for Fabric
17721772
assert call_args[1]["autocommit"] is True
1773-
1774-
1775-
def test_mssql_driver_defaults(make_config):
1776-
"""Test driver defaults for MSSQL connection config.
1777-
1778-
Ensures MSSQL defaults to 'pymssql' but can be overridden to 'pyodbc'.
1779-
"""
1780-
1781-
# Test 1: MSSQL with no driver specified - should default to pymssql
1782-
config_no_driver = make_config(type="mssql", host="localhost", check_import=False)
1783-
assert isinstance(config_no_driver, MSSQLConnectionConfig)
1784-
assert config_no_driver.driver == "pymssql"
1785-
1786-
# Test 2: MSSQL with explicit pymssql driver
1787-
config_pymssql = make_config(
1788-
type="mssql", host="localhost", driver="pymssql", check_import=False
1789-
)
1790-
assert isinstance(config_pymssql, MSSQLConnectionConfig)
1791-
assert config_pymssql.driver == "pymssql"
1792-
1793-
# Test 3: MSSQL with explicit pyodbc driver
1794-
config_pyodbc = make_config(type="mssql", host="localhost", driver="pyodbc", check_import=False)
1795-
assert isinstance(config_pyodbc, MSSQLConnectionConfig)
1796-
assert config_pyodbc.driver == "pyodbc"
1797-
1798-
1799-
def test_fabric_driver_defaults(make_config):
1800-
"""Test driver defaults for Fabric connection config.
1801-
1802-
Ensures Fabric defaults to 'pyodbc' and cannot be changed to 'pymssql'.
1803-
"""
1804-
1805-
# Test 1: Fabric with no driver specified - should default to pyodbc
1806-
config_no_driver = make_config(type="fabric", host="localhost", check_import=False)
1807-
assert isinstance(config_no_driver, FabricConnectionConfig)
1808-
assert config_no_driver.driver == "pyodbc"
1809-
1810-
# Test 2: Fabric with explicit pyodbc driver
1811-
config_pyodbc = make_config(
1812-
type="fabric", host="localhost", driver="pyodbc", check_import=False
1813-
)
1814-
assert isinstance(config_pyodbc, FabricConnectionConfig)
1815-
assert config_pyodbc.driver == "pyodbc"
1816-
1817-
# Test 3: Fabric with pymssql driver should fail (not allowed)
1818-
with pytest.raises(ConfigError, match=r"Input should be 'pyodbc'"):
1819-
make_config(type="fabric", host="localhost", driver="pymssql", check_import=False)

0 commit comments

Comments
 (0)