|
11 | 11 | from .fields import SQLAlchemyConnectionField
|
12 | 12 |
|
13 | 13 | try:
|
14 |
| - from sqlalchemy_utils import ChoiceType, ScalarListType |
| 14 | + from sqlalchemy_utils import ChoiceType, JSONType, ScalarListType |
15 | 15 | except ImportError:
|
16 | 16 | class ChoiceType(object):
|
17 | 17 | pass
|
18 | 18 |
|
19 | 19 | class ScalarListType(object):
|
20 | 20 | pass
|
21 | 21 |
|
| 22 | + class JSONType(object): |
| 23 | + pass |
| 24 | + |
22 | 25 |
|
23 | 26 | def convert_sqlalchemy_relationship(relationship, registry):
|
24 | 27 | direction = relationship.direction
|
@@ -87,7 +90,8 @@ def convert_sqlalchemy_type(type, column, registry=None):
|
87 | 90 | @convert_sqlalchemy_type.register(postgresql.ENUM)
|
88 | 91 | @convert_sqlalchemy_type.register(postgresql.UUID)
|
89 | 92 | def convert_column_to_string(type, column, registry=None):
|
90 |
| - return String(description=column.doc, required=not(column.nullable)) |
| 93 | + return String(description=getattr(column, 'doc', None), |
| 94 | + required=not(getattr(column, 'nullable', True))) |
91 | 95 |
|
92 | 96 |
|
93 | 97 | @convert_sqlalchemy_type.register(types.SmallInteger)
|
@@ -133,3 +137,8 @@ def convert_postgres_array_to_list(type, column, registry=None):
|
133 | 137 | @convert_sqlalchemy_type.register(postgresql.JSONB)
|
134 | 138 | def convert_json_to_string(type, column, registry=None):
|
135 | 139 | return JSONString(description=column.doc, required=not(column.nullable))
|
| 140 | + |
| 141 | + |
| 142 | +@convert_sqlalchemy_type.register(JSONType) |
| 143 | +def convert_json_type_to_string(type, column, registry=None): |
| 144 | + return JSONString(description=column.doc, required=not(column.nullable)) |
0 commit comments