24
24
from ..fields import UnsortedSQLAlchemyConnectionField , default_connection_field_factory
25
25
from ..registry import Registry , get_global_registry
26
26
from ..types import ORMField , SQLAlchemyObjectType
27
+ from ..utils import SQL_VERSION_HIGHER_EQUAL_THAN_1_4 , is_sqlalchemy_version_less_than
27
28
from .models import (
28
29
Article ,
29
30
CompositeFullName ,
@@ -336,6 +337,22 @@ class TestEnum(enum.IntEnum):
336
337
assert graphene_type ._meta .enum .__members__ ["two" ].value == 2
337
338
338
339
340
+ @pytest .mark .skipif (
341
+ not SQL_VERSION_HIGHER_EQUAL_THAN_1_4 ,
342
+ reason = "SQLAlchemy <1.4 does not support this" ,
343
+ )
344
+ def test_should_columproperty_convert_sqa_20 ():
345
+ field = get_field_from_column (
346
+ column_property (select (func .sum (func .cast (id , types .Integer ))).where (id == 1 ))
347
+ )
348
+
349
+ assert field .type == graphene .Int
350
+
351
+
352
+ @pytest .mark .skipif (
353
+ not is_sqlalchemy_version_less_than ("2.0.0b1" ),
354
+ reason = "SQLAlchemy >=2.0 does not support this syntax, see convert_sqa_20" ,
355
+ )
339
356
def test_should_columproperty_convert ():
340
357
field = get_field_from_column (
341
358
column_property (select ([func .sum (func .cast (id , types .Integer ))]).where (id == 1 ))
@@ -355,10 +372,18 @@ def test_should_jsontype_convert_jsonstring():
355
372
assert get_field (types .JSON ).type == graphene .JSONString
356
373
357
374
375
+ @pytest .mark .skipif (
376
+ (not is_sqlalchemy_version_less_than ("2.0.0b1" )),
377
+ reason = "SQLAlchemy >=2.0 does not support this: Variant is no longer used in SQLAlchemy" ,
378
+ )
358
379
def test_should_variant_int_convert_int ():
359
380
assert get_field (types .Variant (types .Integer (), {})).type == graphene .Int
360
381
361
382
383
+ @pytest .mark .skipif (
384
+ (not is_sqlalchemy_version_less_than ("2.0.0b1" )),
385
+ reason = "SQLAlchemy >=2.0 does not support this: Variant is no longer used in SQLAlchemy" ,
386
+ )
362
387
def test_should_variant_string_convert_string ():
363
388
assert get_field (types .Variant (types .String (), {})).type == graphene .String
364
389
0 commit comments