Skip to content

Commit f07f21b

Browse files
committed
add uuid tests
1 parent 42140da commit f07f21b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/query/test_query_parameters.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import uuid
2+
from symbol import parameters
3+
14
import pytest
25
import ydb
36

@@ -152,3 +155,27 @@ class CustomClass:
152155
typed_value = ydb.TypedValue(expected_value)
153156
with pytest.raises(ValueError):
154157
pool.execute_with_retries(query, parameters={"$a": typed_value})
158+
159+
160+
def test_uuid_send(pool: ydb.QuerySessionPool):
161+
val = uuid.UUID("52F84CBA-B15A-4BF2-9696-161ECA74CB5D")
162+
query = """
163+
DECLARE $val AS UUID;
164+
165+
SELECT CAST($val AS Utf8) AS value
166+
"""
167+
res = pool.execute_with_retries(query, parameters={"$val": ydb.TypedValue(val, ydb.PrimitiveType.UUID)})
168+
actual_value = res[0].rows[0]["value"]
169+
assert actual_value.upper() == str(val).upper()
170+
171+
172+
def test_uuid_read(pool: ydb.QuerySessionPool):
173+
val = uuid.UUID("52F84CBA-B15A-4BF2-9696-161ECA74CB5D")
174+
query = """
175+
DECLARE $val AS Utf8;
176+
177+
SELECT CAST($val AS UUID) AS value
178+
"""
179+
res = pool.execute_with_retries(query, parameters={"$val": ydb.TypedValue(str(val), ydb.PrimitiveType.Utf8)})
180+
actual_value = res[0].rows[0]["value"]
181+
assert actual_value.hex.upper() == val.hex.upper()

0 commit comments

Comments
 (0)