Skip to content

Commit 64839d3

Browse files
committed
Map pg's uuid to graphene's uuid
1 parent c89cf80 commit 64839d3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

graphene_sqlalchemy/converter.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from sqlalchemy.dialects import postgresql
44
from sqlalchemy.orm import interfaces
55

6-
from graphene import (ID, Boolean, Dynamic, Enum, Field, Float, Int, List,
7-
String)
6+
from graphene import (ID, UUID, Boolean, Dynamic, Enum, Field, Float, Int,
7+
List, String)
88
from graphene.types.json import JSONString
99

1010
from .enums import enum_for_sa_enum
@@ -191,3 +191,8 @@ def convert_json_to_string(type, column, registry=None):
191191
@convert_sqlalchemy_type.register(JSONType)
192192
def convert_json_type_to_string(type, column, registry=None):
193193
return JSONString
194+
195+
196+
@convert_sqlalchemy_type.register(postgresql.UUID)
197+
def convert_column_to_uuid(type, column, registry=None):
198+
return UUID

graphene_sqlalchemy/tests/test_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class Meta:
252252

253253

254254
def test_should_postgresql_uuid_convert():
255-
assert get_field(postgresql.UUID()).type == graphene.String
255+
assert get_field(postgresql.UUID()).type == graphene.UUID
256256

257257

258258
def test_should_postgresql_enum_convert():

0 commit comments

Comments
 (0)