utils: allow ResourceUUID to convert UUID
Change-Id: I8c26811577bc8175917d1860c73ec266439d49dd
This commit is contained in:
@@ -1186,8 +1186,7 @@ class QueryTransformer(object):
|
|||||||
|
|
||||||
if isinstance(attr.type, base.TimestampUTC):
|
if isinstance(attr.type, base.TimestampUTC):
|
||||||
converter = utils.to_datetime
|
converter = utils.to_datetime
|
||||||
elif (isinstance(attr.type, sqlalchemy_utils.UUIDType)
|
elif isinstance(attr.type, sqlalchemy_utils.UUIDType):
|
||||||
and not isinstance(value, uuid.UUID)):
|
|
||||||
converter = utils.ResourceUUID
|
converter = utils.ResourceUUID
|
||||||
elif isinstance(attr.type, types.String):
|
elif isinstance(attr.type, types.String):
|
||||||
converter = six.text_type
|
converter = six.text_type
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ RESOURCE_ID_NAMESPACE = uuid.UUID('0a7a15ff-aa13-4ac2-897c-9bdf30ce175b')
|
|||||||
|
|
||||||
|
|
||||||
def ResourceUUID(value):
|
def ResourceUUID(value):
|
||||||
|
if isinstance(value, uuid.UUID):
|
||||||
|
return value
|
||||||
if '/' in value:
|
if '/' in value:
|
||||||
raise ValueError("'/' is not supported in resource id")
|
raise ValueError("'/' is not supported in resource id")
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user