Skip to content

Commit cfa9660

Browse files
authored
Merge pull request #6 from RegBinder/convert-int-label-column
Convert int label column for SQLAlchemy column_property
2 parents 1a08d33 + 05fac7d commit cfa9660

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

graphene_sqlalchemy/converter.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ def convert_column_to_datetime(type, column, registry=None):
105105
@convert_sqlalchemy_type.register(types.Integer)
106106
def convert_column_to_int_or_id(type, column, registry=None):
107107
if column.primary_key:
108-
return ID(description=column.doc, required=not(column.nullable))
108+
return ID(description=column.doc, required=not (column.nullable))
109109
else:
110-
return Int(description=column.doc, required=not(column.nullable))
110+
return Int(description=getattr(column, 'doc', None),
111+
required=not (getattr(column, 'nullable', True)))
111112

112113

113114
@convert_sqlalchemy_type.register(types.Boolean)

graphene_sqlalchemy/tests/test_converter.py

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

116116

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

0 commit comments

Comments
 (0)