Skip to content

Commit 9481682

Browse files
committed
Robustify SQLA version determination logic
1 parent 3dd6556 commit 9481682

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

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

0 commit comments

Comments
 (0)