Skip to content

Commit 259ddc3

Browse files
authored
Merge pull request #88 from schireson/dc/sqlachemy-2-compat
2 parents 18ab2eb + 6ef0f3c commit 259ddc3

File tree

172 files changed

+577
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+577
-318
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
26-
pytest-version: ["6.2", "7.0"]
27-
pytest-asyncio-version: ["0.16", "0.19"]
28-
sqlalchemy-version: ["1.3", "1.4"]
26+
pytest-version: ["6.2.0", "7.0.0"]
27+
pytest-asyncio-version: ["0.16.0", "0.19.0"]
28+
sqlalchemy-version: ["1.3.0", "1.4.0", "2.0.0"]
2929

3030
steps:
3131
- uses: actions/checkout@v3

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ build:
88
poetry build
99

1010
test:
11-
COVERAGE_PROCESS_START="$(PWD)/pyproject.toml" \
11+
SQLALCHEMY_WARN_20=1 COVERAGE_PROCESS_START="$(PWD)/pyproject.toml" \
1212
coverage run -m pytest src tests -vv
1313
coverage combine
1414
coverage report -i
1515
coverage xml
1616

1717
lint:
18-
ruff src tests || exit 1
19-
black --check src tests || exit 1
18+
ruff src tests examples || exit 1
19+
black --check src tests examples || exit 1
2020
mypy src tests || exit 1
2121

2222
format:
23-
ruff --fix src tests
24-
black src tests
23+
ruff --fix src tests examples
24+
black src tests examples
2525

2626
publish: build
2727
poetry publish -u __token__ -p '${PYPI_TOKEN}' --no-interaction

docs/source/asyncio.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ thus fixes :ref:`test_downgrade_leaves_no_trace`.
109109
if isinstance(connectable, AsyncEngine):
110110
asyncio.run(run_async_migrations(connectable))
111111
else:
112-
do_run_migrations(connectable)
112+
with connectable.connect() as connection:
113+
do_run_migrations(connection)
113114
114115
115116
# Then use their setup for async connection/running of the migration

docs/source/experimental_tests.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ after its definition.
7171
7272
import sqlalchemy
7373
from sqlalchemy import Column, types
74-
from sqlalchemy.ext.declarative import declarative_base
74+
75+
try:
76+
from sqlalchemy.orm import declarative_base
77+
except ImportError:
78+
from sqlalchemy.ext.declarative import declarative_base
7579
7680
Base = declarative_base()
7781

examples/test_alternative_script_location/alembic/env.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from logging.config import fileConfig
22

33
from alembic import context
4-
from sqlalchemy import engine_from_config, pool
5-
64
from models import Base
5+
from sqlalchemy import engine_from_config, pool
76

87
fileConfig(context.config.config_file_name)
98
target_metadata = Base.metadata

examples/test_alternative_script_location/alembic/versions/aaaaaaaaaaaa_create_foo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from alembic import op
21
import sqlalchemy as sa
2+
from alembic import op
33

44
revision = "aaaaaaaaaaaa"
55
down_revision = None

examples/test_alternative_script_location/alembic/versions/bbbbbbbbbbbb_update_foo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from alembic import op
2+
from sqlalchemy import text
23

34
revision = "bbbbbbbbbbbb"
45
down_revision = "aaaaaaaaaaaa"
@@ -8,7 +9,7 @@
89

910
def upgrade():
1011
conn = op.get_bind()
11-
result = conn.execute("SELECT * FROM foo").fetchall()
12+
result = conn.execute(text("SELECT * FROM foo")).fetchall()
1213
assert len(result) == 0
1314

1415

examples/test_alternative_script_location/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import sqlalchemy
22
from sqlalchemy import Column, types
3-
from sqlalchemy.ext.declarative import declarative_base
3+
4+
try:
5+
from sqlalchemy.orm import declarative_base
6+
except ImportError:
7+
from sqlalchemy.ext.declarative import declarative_base
8+
49

510
Base = declarative_base()
611

examples/test_ambiguous_downgrade_history/migrations/env.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from logging.config import fileConfig
22

33
from alembic import context
4-
from sqlalchemy import engine_from_config, pool
5-
64
from models import Base
5+
from sqlalchemy import engine_from_config, pool
76

87
fileConfig(context.config.config_file_name)
98
target_metadata = Base.metadata

examples/test_ambiguous_downgrade_history/migrations/versions/10483a8dd3c8.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
"""
2-
Revision ID: 10483a8dd3c8
1+
"""Revision ID: 10483a8dd3c8
32
Revises: first
4-
Create Date: 2020-07-01 16:44:05.244310
3+
Create Date: 2020-07-01 16:44:05.244310.
54
"""
65
# revision identifiers, used by Alembic.
7-
revision = '10483a8dd3c8'
8-
down_revision = 'first'
6+
revision = "10483a8dd3c8"
7+
down_revision = "first"
98
branch_labels = None
109
depends_on = None
1110

11+
1212
def upgrade():
1313
pass
1414

0 commit comments

Comments
 (0)