From e84da70e38bf72766927ac3869f51bd0a1508837 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Mon, 7 Oct 2024 17:13:26 +0300 Subject: [PATCH 1/3] add uuid tests --- tests/query/test_query_parameters.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/query/test_query_parameters.py b/tests/query/test_query_parameters.py index 4fccca0f..950a2dfc 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("52F84CBA-B15A-4BF2-9696-161ECA74CB5D") + 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("52F84CBA-B15A-4BF2-9696-161ECA74CB5D") + 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() From be9195e15c98125e29781b65046f1d929a4fb391 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Tue, 29 Oct 2024 15:50:59 +0300 Subject: [PATCH 2/3] change uuid --- tests/query/test_query_parameters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/query/test_query_parameters.py b/tests/query/test_query_parameters.py index 950a2dfc..e7404019 100644 --- a/tests/query/test_query_parameters.py +++ b/tests/query/test_query_parameters.py @@ -157,7 +157,7 @@ class CustomClass: def test_uuid_send(pool: ydb.QuerySessionPool): - val = uuid.UUID("52F84CBA-B15A-4BF2-9696-161ECA74CB5D") + val = uuid.UUID("6E73B41C-4EDE-4D08-9CFB-B7462D9E498B") query = """ DECLARE $val AS UUID; @@ -169,7 +169,7 @@ def test_uuid_send(pool: ydb.QuerySessionPool): def test_uuid_read(pool: ydb.QuerySessionPool): - val = uuid.UUID("52F84CBA-B15A-4BF2-9696-161ECA74CB5D") + val = uuid.UUID("6E73B41C-4EDE-4D08-9CFB-B7462D9E498B") query = """ DECLARE $val AS Utf8; From d14d8751434c4f91364fa0a0baa3e279c27f3f37 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Tue, 29 Oct 2024 15:54:43 +0300 Subject: [PATCH 3/3] remove trailing spaces --- tests/query/test_query_parameters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/query/test_query_parameters.py b/tests/query/test_query_parameters.py index e7404019..4171f5eb 100644 --- a/tests/query/test_query_parameters.py +++ b/tests/query/test_query_parameters.py @@ -161,7 +161,7 @@ def test_uuid_send(pool: ydb.QuerySessionPool): query = """ DECLARE $val AS UUID; -SELECT CAST($val AS Utf8) AS value +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"] @@ -173,7 +173,7 @@ def test_uuid_read(pool: ydb.QuerySessionPool): query = """ DECLARE $val AS Utf8; -SELECT CAST($val AS UUID) AS value +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"]