From 3b359b4fbeabe72648ec9d233dcba75783b2b7ed Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 26 Jun 2023 15:30:37 +0200 Subject: [PATCH 1/5] Added new SQLAlchemy versions --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b104d80ac5..ff03592d44 100644 --- a/tox.ini +++ b/tox.ini @@ -147,7 +147,7 @@ envlist = {py3.8,py3.9,py3.10,py3.11}-starlite # SQL Alchemy - {py2.7,py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{1.2,1.3} + {py2.7,py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{1.2,1.3,1.4,2.0} # Tornado {py3.7,py3.8,py3.9}-tornado-v{5} @@ -426,6 +426,8 @@ deps = # SQLAlchemy sqlalchemy-v1.2: sqlalchemy>=1.2,<1.3 sqlalchemy-v1.3: sqlalchemy>=1.3,<1.4 + sqlalchemy-v1.4: sqlalchemy>=1.4,<2.0 + sqlalchemy-v2.0: sqlalchemy>=2.0,<2.1 # Tornado tornado-v5: tornado>=5,<6 From 5377a7924ccdeee18de9ddff15ad1c3585262fd5 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 26 Jun 2023 15:34:14 +0200 Subject: [PATCH 2/5] SQLAlchemy2 does not support Python2 --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ff03592d44..b112955d57 100644 --- a/tox.ini +++ b/tox.ini @@ -147,7 +147,8 @@ envlist = {py3.8,py3.9,py3.10,py3.11}-starlite # SQL Alchemy - {py2.7,py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{1.2,1.3,1.4,2.0} + {py2.7,py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{1.2,1.3,1.4} + {py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{2.0} # Tornado {py3.7,py3.8,py3.9}-tornado-v{5} From 60a435d3f7a975c002a40e9aed7c394490b6ec38 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 26 Jun 2023 15:44:35 +0200 Subject: [PATCH 3/5] Lets focus on 1.4 first. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b112955d57..a6eac9a3c1 100644 --- a/tox.ini +++ b/tox.ini @@ -148,7 +148,7 @@ envlist = # SQL Alchemy {py2.7,py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{1.2,1.3,1.4} - {py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{2.0} +# {py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{2.0} # Tornado {py3.7,py3.8,py3.9}-tornado-v{5} From ee28500f4e9d0e0f870929f290b9f97ca9ab9038 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 26 Jun 2023 15:48:38 +0200 Subject: [PATCH 4/5] Turns out it works in 1.4, on to 2.0 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index a6eac9a3c1..b112955d57 100644 --- a/tox.ini +++ b/tox.ini @@ -148,7 +148,7 @@ envlist = # SQL Alchemy {py2.7,py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{1.2,1.3,1.4} -# {py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{2.0} + {py3.7,py3.8,py3.9,py3.10,py3.11}-sqlalchemy-v{2.0} # Tornado {py3.7,py3.8,py3.9}-tornado-v{5} From 08c10265eeae2b2fcc685dd878f0ee376ae1a9a8 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 26 Jun 2023 15:58:22 +0200 Subject: [PATCH 5/5] Added some fixes --- tests/integrations/sqlalchemy/test_sqlalchemy.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/integrations/sqlalchemy/test_sqlalchemy.py b/tests/integrations/sqlalchemy/test_sqlalchemy.py index 064af3c4f1..e647d1eb8f 100644 --- a/tests/integrations/sqlalchemy/test_sqlalchemy.py +++ b/tests/integrations/sqlalchemy/test_sqlalchemy.py @@ -5,6 +5,7 @@ from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, sessionmaker +from sqlalchemy import text from sentry_sdk import capture_message, start_transaction, configure_scope from sentry_sdk.consts import SPANDATA @@ -152,7 +153,7 @@ def test_long_sql_query_preserved(sentry_init, capture_events): engine = create_engine("sqlite:///:memory:") with start_transaction(name="test"): with engine.connect() as con: - con.execute(" UNION ".join("SELECT {}".format(i) for i in range(100))) + con.execute(text(" UNION ".join("SELECT {}".format(i) for i in range(100)))) (event,) = events description = event["spans"][0]["description"] @@ -180,7 +181,9 @@ def processor(event, hint): with start_transaction(name="test"): with engine.connect() as con: for _ in range(1500): - con.execute(" UNION ".join("SELECT {}".format(i) for i in range(100))) + con.execute( + text(" UNION ".join("SELECT {}".format(i) for i in range(100))) + ) (event,) = events @@ -218,4 +221,4 @@ def test_engine_name_not_string(sentry_init): engine.dialect.name = b"sqlite" with engine.connect() as con: - con.execute("SELECT 0") + con.execute(text("SELECT 0"))