Skip to content

Added tests for correctness UUID #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 7, 2024
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