Skip to content

Commit 646efbf

Browse files
authored
Robustify SQLA version determination logic (#647)
1 parent b40971e commit 646efbf

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Source code is also available at:
2121
- Refactor column reflection internals into dedicated helpers to reduce complexity without changing behavior.
2222
- Add `pytest-xdist` parallel test support via per-worker schema provisioning hooks.
2323
- Bump `pandas` lower bound in `sa14` test environment from `<2.1` to `>=2.1.1,<2.2` to ensure pre-built wheels are available for Python 3.12
24+
- Fix SQLAlchemy version parsing (SNOW-3066571)
2425

2526
# Release Notes
2627

src/snowflake/sqlalchemy/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
string_types = (str,)
1212
returns_unicode = util.symbol("RETURNS_UNICODE")
1313

14-
IS_VERSION_20 = tuple(int(v) for v in SA_VERSION.split(".")) >= (2, 0, 0)
14+
IS_VERSION_20 = tuple(int(v) for v in SA_VERSION.split(".")[:2]) >= (2, 0)
1515

1616

1717
def args_reducer(positions_to_drop: tuple):

tests/test_compat.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
3+
#
4+
import importlib
5+
6+
import pytest
7+
8+
import snowflake.sqlalchemy.compat as compat_module
9+
10+
11+
@pytest.fixture(scope="session", autouse=True)
12+
def init_test_schema():
13+
"""Neutralize the fixture that requires a live db connection."""
14+
yield
15+
16+
17+
@pytest.mark.parametrize(
18+
("version", "expected"),
19+
[
20+
("2.0.0", True),
21+
("3.1.0", True),
22+
("1.3.0", False),
23+
("2.0.5.post1", True),
24+
("2.0.0rc2", True),
25+
("2.0.0b1", True),
26+
("0.5.0beta3", False),
27+
("0.4.2a", False),
28+
],
29+
)
30+
def test_is_version_20(version, expected, monkeypatch):
31+
monkeypatch.setattr("sqlalchemy.__version__", version)
32+
importlib.reload(compat_module)
33+
assert compat_module.IS_VERSION_20 == expected

0 commit comments

Comments
 (0)