This repository was archived by the owner on Aug 5, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
tests/integration/cqlengine/columns Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515from copy import deepcopy , copy
1616from datetime import date , datetime
1717import logging
18- import re
1918import six
2019import warnings
2120
@@ -518,18 +517,19 @@ class UUID(Column):
518517 """
519518 db_type = 'uuid'
520519
521- re_uuid = re .compile (r'[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}' )
522-
523520 def validate (self , value ):
524521 val = super (UUID , self ).validate (value )
525522 if val is None :
526523 return
527524 from uuid import UUID as _UUID
528525 if isinstance (val , _UUID ):
529526 return val
530- if isinstance (val , six .string_types ) and self .re_uuid .match (val ):
531- return _UUID (val )
532- raise ValidationError ("{} {} is not a valid uuid" .format (self .column_name , value ))
527+ if isinstance (val , six .string_types ):
528+ try :
529+ return _UUID (val )
530+ except ValueError :
531+ raise ValidationError ("{} {} is not a valid uuid" .format (
532+ self .column_name , value ))
533533
534534 def to_python (self , value ):
535535 return self .validate (value )
Original file line number Diff line number Diff line change @@ -240,6 +240,13 @@ def test_uuid_str_no_dashes(self):
240240 t1 = self .UUIDTest .get (test_id = 1 )
241241 assert a_uuid == t1 .a_uuid
242242
243+ def test_uuid_with_upcase (self ):
244+ a_uuid = uuid4 ()
245+ val = str (a_uuid ).upper ()
246+ t0 = self .UUIDTest .create (test_id = 0 , a_uuid = val )
247+ t1 = self .UUIDTest .get (test_id = 0 )
248+ assert a_uuid == t1 .a_uuid
249+
243250class TestTimeUUID (BaseCassEngTestCase ):
244251 class TimeUUIDTest (Model ):
245252
You can’t perform that action at this time.
0 commit comments