Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for SQLAlchemy 2.0 #2200

Merged
merged 5 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/integrations/sqlalchemy/test_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"))
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}
{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}
Expand Down Expand Up @@ -426,6 +427,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
Expand Down