Skip to content

Commit e84da70

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

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/query/test_query_parameters.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import uuid
2+
13
import pytest
24
import ydb
35

@@ -152,3 +154,27 @@ class CustomClass:
152154
typed_value = ydb.TypedValue(expected_value)
153155
with pytest.raises(ValueError):
154156
pool.execute_with_retries(query, parameters={"$a": typed_value})
157+
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+
171+
def test_uuid_read(pool: ydb.QuerySessionPool):
172+
val = uuid.UUID("52F84CBA-B15A-4BF2-9696-161ECA74CB5D")
173+
query = """
174+
DECLARE $val AS Utf8;
175+
176+
SELECT CAST($val AS UUID) AS value
177+
"""
178+
res = pool.execute_with_retries(query, parameters={"$val": ydb.TypedValue(str(val), ydb.PrimitiveType.Utf8)})
179+
actual_value = res[0].rows[0]["value"]
180+
assert actual_value.hex.upper() == val.hex.upper()

0 commit comments

Comments
 (0)