Skip to content

Commit 15b1a8d

Browse files
author
Greg Svitak
committed
adding support to convert int label columns similar to PR#2
1 parent e437058 commit 15b1a8d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

graphene_sqlalchemy/converter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def convert_column_to_int_or_id(type, column, registry=None):
101101
if column.primary_key:
102102
return ID(description=column.doc, required=not(column.nullable))
103103
else:
104-
return Int(description=column.doc, required=not(column.nullable))
104+
return Int(description=getattr(column, 'doc', None),
105+
required=not(getattr(column, 'nullable', True)))
105106

106107

107108
@convert_sqlalchemy_type.register(types.Boolean)

graphene_sqlalchemy/tests/test_converter.py

+5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ def test_should_label_convert_string():
113113
assert isinstance(graphene_type, graphene.String)
114114

115115

116+
def test_should_label_convert_int():
117+
label = Label('int_label_test', case([], else_="foo"), type_=types.Integer())
118+
graphene_type = convert_sqlalchemy_column(label)
119+
assert isinstance(graphene_type, graphene.Int)
120+
116121
def test_should_choice_convert_enum():
117122
TYPES = [
118123
(u'es', u'Spanish'),

0 commit comments

Comments
 (0)