Skip to content

Commit c150aa8

Browse files
committed
upd (converter): add sqlalchemy.types.Variant handling
1 parent 2f1bb7f commit c150aa8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

graphene_sqlalchemy/converter.py

+5
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,8 @@ def convert_json_to_string(type, column, registry=None):
252252
@convert_sqlalchemy_type.register(types.JSON)
253253
def convert_json_type_to_string(type, column, registry=None):
254254
return JSONString
255+
256+
257+
@convert_sqlalchemy_type.register(types.Variant)
258+
def convert_variant_to_impl_type(type, column, registry=None):
259+
return convert_sqlalchemy_type(type.impl, column, registry=registry)

graphene_sqlalchemy/tests/test_converter.py

+8
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@ class Meta:
287287
assert graphene_type.type == A
288288

289289

290+
def test_should_variant_int_convert_int():
291+
assert get_field(types.Variant(types.Integer(), {})).type == graphene.Int
292+
293+
294+
def test_should_variant_string_convert_string():
295+
assert get_field(types.Variant(types.String(), {})).type == graphene.String
296+
297+
290298
def test_should_postgresql_uuid_convert():
291299
assert get_field(postgresql.UUID()).type == graphene.String
292300

0 commit comments

Comments
 (0)