Skip to content

Commit 1fc0cf7

Browse files
authored
feat: Fix for UUID (#70)
This corrects the Marshalling for the UUID Scalar. Referenced in: cloudquery/cloudquery#14825 It assumes Network-Order Bytes as per https://www.rfc-editor.org/rfc/rfc4122.html#section-4.1.1 This should work as it does pass the tests, but our testing framework is a little incomplete. I'm not going to alter the test framework in this commit - But we should have a Marshalling test that confirms the expected bytes are created for each custom object type.
1 parent 7f618e5 commit 1fc0cf7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cloudquery/sdk/scalar/uuid.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
class UUID(Scalar):
66
def __init__(self, valid: bool = False, value: uuid.UUID = None):
7+
if isinstance(value, uuid.UUID):
8+
value = value.bytes
79
super().__init__(valid, value)
810

911
def __eq__(self, scalar: Scalar) -> bool:
@@ -27,11 +29,13 @@ def set(self, value: any):
2729
self._value = value.value
2830
return
2931

30-
if isinstance(value, uuid.UUID):
32+
if isinstance(value, bytes):
3133
self._value = value
34+
elif isinstance(value, uuid.UUID):
35+
self._value = value.bytes
3236
elif isinstance(value, str):
3337
try:
34-
self._value = uuid.UUID(value)
38+
self._value = uuid.UUID(value).bytes
3539
except ValueError as e:
3640
raise ScalarInvalidTypeError("Invalid type for UUID scalar") from e
3741
else:

0 commit comments

Comments
 (0)