-
Notifications
You must be signed in to change notification settings - Fork 227
feat: SQLAlchemy 2.0 support #368
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
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2e321e9
chore: prepare for sqlalchemy2.0 adjustments
erikwrede e4b1a7f
update envlist for tox,reduce number of python versions
erikwrede 812b28b
fix: set sqlalchemy max version to 2.1
erikwrede 7288117
fix: all unit tests running
erikwrede e562cc2
fix: corrected sql version check for batching
erikwrede e525a8d
fix: added pragma no cover to version checks
erikwrede b84aa9f
chore: test with all python versions
erikwrede 39834ed
chore: fix review comments
erikwrede a9915d6
chore: update dependencies and fix test
erikwrede 4712e10
chore: update sqa-utils fix
erikwrede cf0ba76
Merge branch 'master' into sqa-2.0
erikwrede a0abf8a
fix: adjust test after sqlalchemy 2.0 update
erikwrede File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
from ..fields import UnsortedSQLAlchemyConnectionField, default_connection_field_factory | ||
from ..registry import Registry, get_global_registry | ||
from ..types import ORMField, SQLAlchemyObjectType | ||
from ..utils import SQL_VERSION_HIGHER_EQUAL_THAN_1_4, is_sqlalchemy_version_less_than | ||
from .models import ( | ||
Article, | ||
CompositeFullName, | ||
|
@@ -336,6 +337,22 @@ class TestEnum(enum.IntEnum): | |
assert graphene_type._meta.enum.__members__["two"].value == 2 | ||
|
||
|
||
@pytest.mark.skipif( | ||
not SQL_VERSION_HIGHER_EQUAL_THAN_1_4, | ||
reason="SQLAlchemy <1.4 does not support this", | ||
) | ||
def test_should_columproperty_convert_sqa_20(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: You could hand the select function and parametrize the test depending on the SQL version 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good Idea! |
||
field = get_field_from_column( | ||
column_property(select(func.sum(func.cast(id, types.Integer))).where(id == 1)) | ||
) | ||
|
||
assert field.type == graphene.Int | ||
|
||
|
||
@pytest.mark.skipif( | ||
not is_sqlalchemy_version_less_than("2.0.0b1"), | ||
reason="SQLAlchemy >=2.0 does not support this syntax, see convert_sqa_20", | ||
) | ||
def test_should_columproperty_convert(): | ||
field = get_field_from_column( | ||
column_property(select([func.sum(func.cast(id, types.Integer))]).where(id == 1)) | ||
|
@@ -355,10 +372,18 @@ def test_should_jsontype_convert_jsonstring(): | |
assert get_field(types.JSON).type == graphene.JSONString | ||
|
||
|
||
@pytest.mark.skipif( | ||
(not is_sqlalchemy_version_less_than("2.0.0b1")), | ||
reason="SQLAlchemy >=2.0 does not support this: Variant is no longer used in SQLAlchemy", | ||
) | ||
def test_should_variant_int_convert_int(): | ||
assert get_field(types.Variant(types.Integer(), {})).type == graphene.Int | ||
|
||
|
||
@pytest.mark.skipif( | ||
(not is_sqlalchemy_version_less_than("2.0.0b1")), | ||
reason="SQLAlchemy >=2.0 does not support this: Variant is no longer used in SQLAlchemy", | ||
) | ||
def test_should_variant_string_convert_string(): | ||
assert get_field(types.Variant(types.String(), {})).type == graphene.String | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.