Skip to content

Missing sqlalchemy utils issue #76

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 5 additions & 12 deletions graphene_sqlalchemy/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@
from .fields import createConnectionField

try:
from sqlalchemy_utils import ChoiceType, JSONType, ScalarListType, TSVectorType
from sqlalchemy_utils import (
ChoiceType, JSONType, ScalarListType, TSVectorType)
except ImportError:
class ChoiceType(object):
pass

class ScalarListType(object):
pass

class JSONType(object):
pass
ChoiceType = JSONType = ScalarListType = TSVectorType = object


def get_column_doc(column):
Expand All @@ -38,10 +32,9 @@ def dynamic_type():
_type = registry.get_type_for_model(model)
if not _type:
return None
if (direction == interfaces.MANYTOONE or not relationship.uselist):
if direction == interfaces.MANYTOONE or not relationship.uselist:
return Field(_type)
elif (direction == interfaces.ONETOMANY or
direction == interfaces.MANYTOMANY):
elif direction in (interfaces.ONETOMANY, interfaces.MANYTOMANY):
if _type._meta.connection:
return createConnectionField(_type)
return Field(List(_type))
Expand Down
8 changes: 4 additions & 4 deletions graphene_sqlalchemy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):
is_excluded = name in exclude_fields # or is_already_created
if is_not_in_only or is_excluded:
# We skip this field if we specify only_fields and is not
# in there. Or when we excldue this field in exclude_fields
# in there. Or when we exclude this field in exclude_fields
continue
converted_column = convert_sqlalchemy_column(column, registry)
fields[name] = converted_column
Expand All @@ -39,7 +39,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):
is_excluded = name in exclude_fields # or is_already_created
if is_not_in_only or is_excluded:
# We skip this field if we specify only_fields and is not
# in there. Or when we excldue this field in exclude_fields
# in there. Or when we exclude this field in exclude_fields
continue
converted_composite = convert_sqlalchemy_composite(composite, registry)
fields[name] = converted_composite
Expand All @@ -55,7 +55,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):

if is_not_in_only or is_excluded:
# We skip this field if we specify only_fields and is not
# in there. Or when we excldue this field in exclude_fields
# in there. Or when we exclude this field in exclude_fields
continue

converted_hybrid_property = convert_sqlalchemy_hybrid_method(
Expand All @@ -70,7 +70,7 @@ def construct_fields(model, registry, only_fields, exclude_fields):
is_excluded = relationship.key in exclude_fields # or is_already_created
if is_not_in_only or is_excluded:
# We skip this field if we specify only_fields and is not
# in there. Or when we excldue this field in exclude_fields
# in there. Or when we exclude this field in exclude_fields
continue
converted_relationship = convert_sqlalchemy_relationship(relationship, registry)
name = relationship.key
Expand Down