Skip to content

Commit b0a9b84

Browse files
committed
merge master
1 parent 00e16af commit b0a9b84

File tree

3 files changed

+38
-29
lines changed

3 files changed

+38
-29
lines changed

graphene_sqlalchemy/tests/models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
from graphene_sqlalchemy.utils import SQL_VERSION_HIGHER_EQUAL_THAN_1_4, SQL_VERSION_HIGHER_EQUAL_THAN_2
2727

2828
# fmt: off
29-
import sqlalchemy
3029
if SQL_VERSION_HIGHER_EQUAL_THAN_2:
31-
from sqlalchemy.sql.sqltypes import HasExpressionLookup # noqa # isort:skip
30+
from sqlalchemy.sql.sqltypes import HasExpressionLookup # noqa # isort:skip
3231
else:
33-
from sqlalchemy.sql.sqltypes import _LookupExpressionAdapter as HasExpressionLookup # noqa # isort:skip
32+
from sqlalchemy.sql.sqltypes import _LookupExpressionAdapter as HasExpressionLookup # noqa # isort:skip
3433
# fmt: on
3534

3635
PetKind = Enum("cat", "dog", name="pet_kind")

graphene_sqlalchemy/types.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,15 @@ class SQLAlchemyObjectType(SQLAlchemyBase, ObjectType):
408408
409409
Usage:
410410
411-
class MyModel(Base):
412-
id = Column(Integer(), primary_key=True)
413-
name = Column(String())
411+
.. code-block:: python
414412
415-
class MyType(SQLAlchemyObjectType):
416-
class Meta:
417-
model = MyModel
413+
class MyModel(Base):
414+
id = Column(Integer(), primary_key=True)
415+
name = Column(String())
416+
417+
class MyType(SQLAlchemyObjectType):
418+
class Meta:
419+
model = MyModel
418420
"""
419421

420422
@classmethod
@@ -450,30 +452,32 @@ class SQLAlchemyInterface(SQLAlchemyBase, Interface):
450452
451453
Usage (using joined table inheritance):
452454
453-
class MyBaseModel(Base):
454-
id = Column(Integer(), primary_key=True)
455-
type = Column(String())
456-
name = Column(String())
455+
.. code-block:: python
457456
458-
__mapper_args__ = {
459-
"polymorphic_on": type,
460-
}
457+
class MyBaseModel(Base):
458+
id = Column(Integer(), primary_key=True)
459+
type = Column(String())
460+
name = Column(String())
461461
462-
class MyChildModel(Base):
463-
date = Column(Date())
462+
__mapper_args__ = {
463+
"polymorphic_on": type,
464+
}
464465
465-
__mapper_args__ = {
466-
"polymorphic_identity": "child",
467-
}
466+
class MyChildModel(Base):
467+
date = Column(Date())
468468
469-
class MyBaseType(SQLAlchemyInterface):
470-
class Meta:
471-
model = MyBaseModel
469+
__mapper_args__ = {
470+
"polymorphic_identity": "child",
471+
}
472472
473-
class MyChildType(SQLAlchemyObjectType):
474-
class Meta:
475-
model = MyChildModel
476-
interfaces = (MyBaseType,)
473+
class MyBaseType(SQLAlchemyInterface):
474+
class Meta:
475+
model = MyBaseModel
476+
477+
class MyChildType(SQLAlchemyObjectType):
478+
class Meta:
479+
model = MyChildModel
480+
interfaces = (MyBaseType,)
477481
"""
478482

479483
@classmethod

graphene_sqlalchemy/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@ def is_graphene_version_less_than(version_string): # pragma: no cover
2727

2828
SQL_VERSION_HIGHER_EQUAL_THAN_1_4 = False
2929

30-
if not is_sqlalchemy_version_less_than("1.4"):
30+
if not is_sqlalchemy_version_less_than("1.4"): # pragma: no cover
3131
from sqlalchemy.ext.asyncio import AsyncSession
3232

3333
SQL_VERSION_HIGHER_EQUAL_THAN_1_4 = True
3434

3535

36+
SQL_VERSION_HIGHER_EQUAL_THAN_2 = False
37+
38+
if not is_sqlalchemy_version_less_than("2.0.0b1"): # pragma: no cover
39+
SQL_VERSION_HIGHER_EQUAL_THAN_2 = True
40+
41+
3642
def get_session(context):
3743
return context.get("session")
3844

0 commit comments

Comments
 (0)