Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/query/test_query_parameters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import uuid

import pytest
import ydb

Expand Down Expand Up @@ -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()
Loading