Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit cf71187

Browse files
harshachintasinhasubham
authored andcommitted
chore: add unit and system tests for UUID
Signed-off-by: Sri Harsha CH <sriharshach@google.com>
1 parent c0d7464 commit cf71187

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

google/cloud/spanner_v1/streamed.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def _merge_struct(lhs, rhs, type_):
394394
TypeCode.PROTO: _merge_string,
395395
TypeCode.INTERVAL: _merge_string,
396396
TypeCode.ENUM: _merge_string,
397+
TypeCode.UUID: _merge_string,
397398
}
398399

399400

tests/system/test_session_api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import struct
2121
import threading
2222
import time
23+
import uuid
24+
2325
import pytest
2426

2527
import grpc
@@ -3056,6 +3058,16 @@ def test_execute_sql_returning_transfinite_floats(sessions_database, not_postgre
30563058
assert math.isnan(float_array[2])
30573059

30583060

3061+
def test_execute_sql_w_uuid_bindings(sessions_database, database_dialect):
3062+
_bind_test_helper(
3063+
sessions_database,
3064+
database_dialect,
3065+
spanner_v1.param_types.UUID,
3066+
uuid.uuid4(),
3067+
[uuid.uuid4(), uuid.uuid4()],
3068+
)
3069+
3070+
30593071
def test_partition_query(sessions_database, not_emulator, not_experimental_host):
30603072
row_count = 40
30613073
sql = f"SELECT * FROM {_sample_data.TABLE}"

tests/unit/test__helpers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515

1616
import unittest
17+
import uuid
18+
1719
import mock
1820

1921
from opentelemetry.sdk.resources import Resource
@@ -786,6 +788,18 @@ def test_w_proto_enum(self):
786788
self._callFUT(value_pb, field_type, field_name, column_info), VALUE
787789
)
788790

791+
def test_w_uuid(self):
792+
from google.protobuf.struct_pb2 import Value
793+
from google.cloud.spanner_v1 import Type
794+
from google.cloud.spanner_v1 import TypeCode
795+
796+
VALUE = uuid.uuid4()
797+
field_type = Type(code=TypeCode.UUID)
798+
field_name = "uuid_column"
799+
value_pb = Value(string_value=str(VALUE))
800+
801+
self.assertEqual(self._callFUT(value_pb, field_type, field_name), VALUE)
802+
789803

790804
class Test_parse_list_value_pbs(unittest.TestCase):
791805
def _callFUT(self, *args, **kw):

0 commit comments

Comments
 (0)