Skip to content

Commit

Permalink
adding support to convert int label columns similar to PR#2
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Svitak committed Sep 25, 2016
1 parent e437058 commit 15b1a8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion graphene_sqlalchemy/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def convert_column_to_int_or_id(type, column, registry=None):
if column.primary_key:
return ID(description=column.doc, required=not(column.nullable))
else:
return Int(description=column.doc, required=not(column.nullable))
return Int(description=getattr(column, 'doc', None),
required=not(getattr(column, 'nullable', True)))


@convert_sqlalchemy_type.register(types.Boolean)
Expand Down
5 changes: 5 additions & 0 deletions graphene_sqlalchemy/tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ def test_should_label_convert_string():
assert isinstance(graphene_type, graphene.String)


def test_should_label_convert_int():
label = Label('int_label_test', case([], else_="foo"), type_=types.Integer())
graphene_type = convert_sqlalchemy_column(label)
assert isinstance(graphene_type, graphene.Int)

def test_should_choice_convert_enum():
TYPES = [
(u'es', u'Spanish'),
Expand Down

0 comments on commit 15b1a8d

Please sign in to comment.