Skip to content

Commit 089cab4

Browse files
committed
add uuid tests
1 parent 42140da commit 089cab4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/query/test_query_parameters.py

Lines changed: 25 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,25 @@ 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+
def test_uuid_send(pool: ydb.QuerySessionPool):
160+
val = uuid.UUID("52F84CBA-B15A-4BF2-9696-161ECA74CB5D")
161+
query = """
162+
DECLARE $val AS UUID;
163+
164+
SELECT CAST($val AS Utf8) AS value
165+
"""
166+
res = pool.execute_with_retries(query, parameters={"$val": ydb.TypedValue(val, ydb.PrimitiveType.UUID)})
167+
actual_value = res[0].rows[0]["value"]
168+
assert actual_value.upper() == str(val).upper()
169+
170+
def test_uuid_read(pool: ydb.QuerySessionPool):
171+
val = uuid.UUID("52F84CBA-B15A-4BF2-9696-161ECA74CB5D")
172+
query = """
173+
DECLARE $val AS Utf8;
174+
175+
SELECT CAST($val AS UUID) AS value
176+
"""
177+
res = pool.execute_with_retries(query, parameters={"$val": ydb.TypedValue(str(val), ydb.PrimitiveType.Utf8)})
178+
actual_value = res[0].rows[0]["value"]
179+
assert actual_value.hex.upper() == val.hex.upper()

0 commit comments

Comments
 (0)