diff --git a/tests/query/test_query_parameters.py b/tests/query/test_query_parameters.py index 4fccca0f..4171f5eb 100644 --- a/tests/query/test_query_parameters.py +++ b/tests/query/test_query_parameters.py @@ -1,3 +1,5 @@ +import uuid + import pytest import ydb @@ -152,3 +154,27 @@ class CustomClass: typed_value = ydb.TypedValue(expected_value) with pytest.raises(ValueError): pool.execute_with_retries(query, parameters={"$a": typed_value}) + + +def test_uuid_send(pool: ydb.QuerySessionPool): + val = uuid.UUID("6E73B41C-4EDE-4D08-9CFB-B7462D9E498B") + query = """ +DECLARE $val AS UUID; + +SELECT CAST($val AS Utf8) AS value +""" + res = pool.execute_with_retries(query, parameters={"$val": ydb.TypedValue(val, ydb.PrimitiveType.UUID)}) + actual_value = res[0].rows[0]["value"] + assert actual_value.upper() == str(val).upper() + + +def test_uuid_read(pool: ydb.QuerySessionPool): + val = uuid.UUID("6E73B41C-4EDE-4D08-9CFB-B7462D9E498B") + query = """ +DECLARE $val AS Utf8; + +SELECT CAST($val AS UUID) AS value +""" + res = pool.execute_with_retries(query, parameters={"$val": ydb.TypedValue(str(val), ydb.PrimitiveType.Utf8)}) + actual_value = res[0].rows[0]["value"] + assert actual_value.hex.upper() == val.hex.upper()