Skip to content

Commit 640cd17

Browse files
authored
Merge branch 'master' into patch-1
2 parents 64aa28b + 8ea2086 commit 640cd17

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

graphene_sqlalchemy/converter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ def convert_scalar_list_to_list(type, column, registry=None):
178178
return List(String)
179179

180180

181+
@convert_sqlalchemy_type.register(types.ARRAY)
181182
@convert_sqlalchemy_type.register(postgresql.ARRAY)
182-
def convert_postgres_array_to_list(_type, column, registry=None):
183+
def convert_array_to_list(_type, column, registry=None):
183184
inner_type = convert_sqlalchemy_type(column.type.item_type, column)
184185
return List(inner_type)
185186

graphene_sqlalchemy/enums.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import six
12
from sqlalchemy.orm import ColumnProperty
23
from sqlalchemy.types import Enum as SQLAlchemyEnumType
34

@@ -62,7 +63,7 @@ def enum_for_field(obj_type, field_name):
6263
if not isinstance(obj_type, type) or not issubclass(obj_type, SQLAlchemyObjectType):
6364
raise TypeError(
6465
"Expected SQLAlchemyObjectType, but got: {!r}".format(obj_type))
65-
if not field_name or not isinstance(field_name, str):
66+
if not field_name or not isinstance(field_name, six.string_types):
6667
raise TypeError(
6768
"Expected a field name, but got: {!r}".format(field_name))
6869
registry = obj_type._meta.registry

graphene_sqlalchemy/fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import warnings
22
from functools import partial
33

4+
import six
45
from promise import Promise, is_thenable
56
from sqlalchemy.orm.query import Query
67

@@ -35,7 +36,7 @@ def model(self):
3536
def get_query(cls, model, info, sort=None, **args):
3637
query = get_query(model, info.context)
3738
if sort is not None:
38-
if isinstance(sort, str):
39+
if isinstance(sort, six.string_types):
3940
query = query.order_by(sort.value)
4041
else:
4142
query = query.order_by(*(col.value for col in sort))

graphene_sqlalchemy/registry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections import defaultdict
22

3+
import six
34
from sqlalchemy.types import Enum as SQLAlchemyEnumType
45

56
from graphene import Enum
@@ -42,7 +43,7 @@ def register_orm_field(self, obj_type, field_name, orm_field):
4243
raise TypeError(
4344
"Expected SQLAlchemyObjectType, but got: {!r}".format(obj_type)
4445
)
45-
if not field_name or not isinstance(field_name, str):
46+
if not field_name or not isinstance(field_name, six.string_types):
4647
raise TypeError("Expected a field name, but got: {!r}".format(field_name))
4748
self._registry_orm_fields[obj_type][field_name] = orm_field
4849

graphene_sqlalchemy/tests/test_converter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ def test_should_postgresql_array_convert():
323323
assert field.type.of_type == graphene.Int
324324

325325

326+
def test_should_array_convert():
327+
field = get_field(types.ARRAY(types.Integer))
328+
assert isinstance(field.type, graphene.List)
329+
assert field.type.of_type == graphene.Int
330+
331+
326332
def test_should_postgresql_json_convert():
327333
assert get_field(postgresql.JSON()).type == graphene.JSONString
328334

0 commit comments

Comments
 (0)