@@ -869,3 +869,49 @@ def test_connection_native_uuid_attribute():
869869 params = sig .parameters
870870 assert "native_uuid" in params , "Connection.__init__ should accept native_uuid parameter"
871871 assert params ["native_uuid" ].default is None
872+
873+
874+ def test_compute_uuid_str_indices_no_description (db_connection ):
875+ """Test _compute_uuid_str_indices returns None when cursor has no description."""
876+ cursor = db_connection .cursor ()
877+ try :
878+ # Execute a statement that produces no result set
879+ cursor .execute (
880+ "CREATE TABLE #no_desc_uuid_test (id INT); " "INSERT INTO #no_desc_uuid_test VALUES (1)"
881+ )
882+ # description should be None after a non-SELECT statement
883+ assert cursor .description is None
884+
885+ # Directly call the helper — should return None via the early guard
886+ result = cursor ._compute_uuid_str_indices ()
887+ assert (
888+ result is None
889+ ), "_compute_uuid_str_indices should return None when description is None"
890+ finally :
891+ cursor .execute ("DROP TABLE IF EXISTS #no_desc_uuid_test" )
892+ cursor .close ()
893+
894+
895+ def test_stringify_uuids_with_tuple_values ():
896+ """Test Row._stringify_uuids converts tuple values to list for in-place mutation."""
897+ import uuid as _uuid
898+ from mssql_python .row import Row
899+
900+ test_uuid = _uuid .UUID ("12345678-1234-5678-1234-567812345678" )
901+
902+ # Pass values as a tuple (not a list) to trigger the isinstance guard
903+ row = Row (
904+ (42 , test_uuid , "hello" ),
905+ {"id" : 0 , "guid" : 1 , "name" : 2 },
906+ cursor = None ,
907+ converter_map = None ,
908+ uuid_str_indices = (1 ,),
909+ )
910+
911+ # The UUID should have been stringified to uppercase
912+ assert row [1 ] == "12345678-1234-5678-1234-567812345678" .upper ()
913+ # Other values should be unaffected
914+ assert row [0 ] == 42
915+ assert row [2 ] == "hello"
916+ # Internal storage should now be a list (converted from tuple)
917+ assert isinstance (row ._values , list )
0 commit comments