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

feat(deps): Bump latest supported sqlalchemy from 1.* to 2.* #1484

Merged
merged 21 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
252c944
chore(deps): Bump sqlalchemy from 1.4.46 to 2.0.5.post1
dependabot[bot] Mar 6, 2023
a1b0c17
Remove 2.0 migration helpers
edgarrmondragon Mar 6, 2023
1183160
Test both SQLAlchemy 1 and 2
edgarrmondragon Mar 16, 2023
06c65ef
Revert "Test both SQLAlchemy 1 and 2"
edgarrmondragon Jun 2, 2023
777a1dd
Fix types
edgarrmondragon Jun 2, 2023
9b752c2
Test also against legacy sqlalchemy
edgarrmondragon Jun 2, 2023
518e977
Identify SQLAlchemy 1.* tests
edgarrmondragon Jun 2, 2023
695038b
Put env var in the right place
edgarrmondragon Jun 2, 2023
3fbe932
Install sqlalchemy with the wrapped Nox session instance
edgarrmondragon Jun 21, 2023
c78cb0c
Fix mypy check
edgarrmondragon Jun 21, 2023
f2513fe
Print SQLAlchemy version in Pytest output
edgarrmondragon Jul 11, 2023
a78c1dc
Remove `sqlalchemy2-stubs`
edgarrmondragon Jul 11, 2023
bc6b0f4
Fix mypy checks
edgarrmondragon Jul 11, 2023
221a15c
Merge branch 'main' into dependabot/pip/sqlalchemy-2.0.5.post1
edgarrmondragon Jul 13, 2023
3bf5df6
Fix click annotations
edgarrmondragon Jul 13, 2023
ad6ffe8
Merge branch 'main' into dependabot/pip/sqlalchemy-2.0.5.post1
edgarrmondragon Jul 13, 2023
54ca85b
Merge branch 'main' into dependabot/pip/sqlalchemy-2.0.5.post1
edgarrmondragon Jul 14, 2023
cbad6a1
Merge branch 'main' into dependabot/pip/sqlalchemy-2.0.5.post1
edgarrmondragon Jul 14, 2023
e2a44fd
Merge branch 'main' into dependabot/pip/sqlalchemy-2.0.5.post1
edgarrmondragon Jul 14, 2023
b97bee5
Merge branch 'main' into dependabot/pip/sqlalchemy-2.0.5.post1
edgarrmondragon Jul 19, 2023
c88a47d
Merge branch 'main' into dependabot/pip/sqlalchemy-2.0.5.post1
edgarrmondragon Jul 20, 2023
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
10 changes: 7 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ env:

jobs:
tests:
name: Test on ${{ matrix.python-version }} (${{ matrix.session }}) / ${{ matrix.os }}
name: "Test on ${{ matrix.python-version }} (${{ matrix.session }}) / ${{ matrix.os }} / SQLAlchemy: ${{ matrix.sqlalchemy }}"
runs-on: ${{ matrix.os }}
env:
NOXSESSION: ${{ matrix.session }}
Expand All @@ -47,9 +47,11 @@ jobs:
session: [tests]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
sqlalchemy: ["2.*"]
include:
- { session: doctest, python-version: "3.10", os: "ubuntu-latest" }
- { session: mypy, python-version: "3.8", os: "ubuntu-latest" }
- { session: tests, python-version: "3.11", os: "ubuntu-latest", sqlalchemy: "1.*" }
- { session: doctest, python-version: "3.10", os: "ubuntu-latest", sqlalchemy: "2.*" }
- { session: mypy, python-version: "3.8", os: "ubuntu-latest", sqlalchemy: "2.*" }

steps:
- name: Check out the repository
Expand Down Expand Up @@ -86,6 +88,8 @@ jobs:
nox --version

- name: Run Nox
env:
SQLALCHEMY_VERSION: ${{ matrix.sqlalchemy }}
run: |
nox --python=${{ matrix.python-version }}

Expand Down
11 changes: 8 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ def tests(session: Session) -> None:
session.install(".[s3]")
session.install(*test_dependencies)

sqlalchemy_version = os.environ.get("SQLALCHEMY_VERSION")
if sqlalchemy_version:
# Bypass nox-poetry use of --constraint so we can install a version of
# SQLAlchemy that doesn't match what's in poetry.lock.
session.poetry.session.install( # type: ignore[attr-defined]
f"sqlalchemy=={sqlalchemy_version}",
)

try:
session.run(
"coverage",
Expand All @@ -95,9 +103,6 @@ def tests(session: Session) -> None:
"-v",
"--durations=10",
*session.posargs,
env={
"SQLALCHEMY_WARN_20": "1",
},
)
finally:
if session.interactive:
Expand Down
124 changes: 57 additions & 67 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ memoization = ">=0.3.2,<0.5.0"
jsonpath-ng = "^1.5.3"
joblib = "^1.0.1"
inflection = "^0.5.1"
sqlalchemy = "^1.4"
sqlalchemy = ">=1.4,<3.0"
python-dotenv = ">=0.20,<0.22"
typing-extensions = "^4.2.0"
simplejson = "^3.17.6"
Expand Down Expand Up @@ -109,7 +109,6 @@ numpy = [
{ version = ">=1.22", python = ">=3.8" },
]
requests-mock = "^1.10.0"
sqlalchemy2-stubs = {version = "^0.0.2a32", allow-prereleases = true}
types-jsonschema = "^4.17.0.6"
types-python-dateutil = "^2.8.19"
types-pytz = ">=2022.7.1.2,<2024.0.0.0"
Expand All @@ -132,9 +131,6 @@ exclude = ".*simpleeval.*"

[tool.pytest.ini_options]
addopts = '-vvv --ignore=singer_sdk/helpers/_simpleeval.py -m "not external"'
filterwarnings = [
"error::sqlalchemy.exc.RemovedIn20Warning",
]
markers = [
"external: Tests relying on external resources",
"windows: Tests that only run on Windows",
Expand Down Expand Up @@ -190,9 +186,6 @@ fail_under = 82
[tool.mypy]
exclude = "tests"
files = "singer_sdk"
plugins = [
"sqlalchemy.ext.mypy.plugin",
]
python_version = "3.8"
warn_unused_configs = true
warn_unused_ignores = true
Expand Down
6 changes: 1 addition & 5 deletions singer_sdk/sinks/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,7 @@ def bulk_insert_records(
if isinstance(insert_sql, str):
insert_sql = sqlalchemy.text(insert_sql)

conformed_records = (
[self.conform_record(record) for record in records]
if isinstance(records, list)
else (self.conform_record(record) for record in records)
)
conformed_records = [self.conform_record(record) for record in records]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execute doesn't really support generators, only sequences (i.e. lists, tuples)

self.logger.info("Inserting with SQL: %s", insert_sql)
with self.connector._connect() as conn, conn.begin():
conn.execute(insert_sql, conformed_records)
Expand Down
Loading