Repository navigation
Add SQLAlchemy 2.1 support - #489
Claire-ovo wants to merge 12 commits into
Conversation
|
CI has finished: Python 3.10 and pre-commit.ci pass; Python 3.11–3.14 fail in the six existing DOMAIN/GeoAlchemy tests noted in the PR description. The eight new regression cases pass. I reproduced all six failures locally with SQLAlchemy 2.1.6, then loaded the unmodified generator from master c7eef1f in the same environment and reran those six tests: they fail identically. With SQLAlchemy 2.0.55 the full suite passes (171 tests). There is also a concrete runtime consequence in the existing DOMAIN path: after a DOMAIN is attached to a table, inherited constructor introspection emits I have kept this PR focused on nested type arguments and have not changed dependency constraints or refreshed unrelated snapshots to hide these failures. I can investigate the 2.1 compatibility work in a separate follow-up if that fits the project's direction. |
|
@Claire-ovo thank you for your contribution. If you want to move forward, please stop using AI for communication. Neither @agronholm nor I should have to go through some semi readable heap of text just to get to the point. Tests should pass before we even begin discussing this PR. |
sheinbergon
left a comment
There was a problem hiding this comment.
We should split the work between supporting SA 2.1 and supporting Clickhouse nested imports. Up to you which do you want to tackle 1st.
As for SA 2.1, should be implemented differently as commented
10x
…lm#489 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@agronholm this is a welcomed addition |
|
@agronholm WDYT? |
|
This almost escaped my attention (I get more PRs I can handle these days). I thought we already supported SQLA 2.1. |
|
Adding support for newer SA is good, but I'll need to review this in depth. I'll try to get that done within the next couple of days. |
|
I feel that some of the tests that are currently duplicated should probably not be. I find it hard to believe that SQLAlchemy 2.1 is so fundamentally different to require that many changes. |
…lm#489 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
379ae3b to
cfa486d
Compare
The SQLAlchemy 2.1 behavior is already covered by the version-parametrized generator tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The pin made the SQLAlchemy 2.1 CI jobs fail at dependency resolution. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
SQLAlchemy 2.1 uses a sentinel default for SchemaType's schema argument and sets the table's metadata on the type when its column is attached to a table, which made both look like non-default arguments. Neither is needed in the generated code, so the output for the plain domain tests is the same on 2.0 and 2.1 again and their version-specific copies are gone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Yes, you were right. Only 3 pairs actually required duplication (domain mapping related) |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@agronholm fixed applied. Looks like we have a lot of small fixes/improvents to release. Please share your thoughts on this PR at it's current state |
agronholm
left a comment
There was a problem hiding this comment.
Just a couple of minor comments worth considering. Otherwise I'm okay with this.
| sqlalchemy: [">=2.0.29,<2.1", ">=2.1,<2.2"] | ||
| exclude: | ||
| # SQLAlchemy 2.1 requires Python 3.11 or later. | ||
| - python-version: "3.10" | ||
| sqlalchemy: ">=2.1,<2.2" |
There was a problem hiding this comment.
This gives us 9 CI jobs. Do we need all of them? We could just add the SQLA 2.0 jobs as inclusions (instructions here).
| - name: Show dependency version | ||
| run: python -c "import sqlalchemy; print(sqlalchemy.__version__)" |
There was a problem hiding this comment.
What do we need this for? The previous step already shows clearly which version is installed.
|
Dropping Python 3.10 might also be worth considering, though it's out of scope for this PR. |
Changes
Adds SQLAlchemy 2.1 support and runs the test suite against both SQLAlchemy 2.0 and 2.1.
_render_column_type_value()now renders aMetaDataargument as the generated module's metadata reference instead ofMetaData(). SQLAlchemy 2.1 attaches PostgreSQLDOMAINtypes to the table's metadata automatically, so generated code referenced an unimportedMetaDatain declarative output (NameError) and detached the domain's DDL from the generated tables._sa20/_sa21variants, selected by a newsqlalchemy_versionfixture that skips the variant not matching the installed version.SQLAlchemy>=2.0.29,<2.1andSQLAlchemy>=2.1,<2.2(2.1 excluded on Python 3.10, which it does not support).tests/test_domain_metadata.pychecks, for all four generators, that the generatedDOMAINshares the generated metadata and thatcreate_all/drop_allemit the domain DDL exactly once.The ClickHouse nested type argument rendering (#469) was split out of this PR.
Checklist