Skip to content

Merge branch 'main' into simdutf

9a30c1a
Select commit
Loading
Failed to load commit list.
Open

FIX: [PERF] Handle utf16 strings using simdutf and std::u16string #526

Merge branch 'main' into simdutf
9a30c1a
Select commit
Loading
Failed to load commit list.
Azure Pipelines / MSSQL-Python-PR-Validation succeeded Apr 22, 2026 in 20m 53s

Build #pr-validation-pipeline had test failures

Details

Tests

  • Failed: 2 (0.01%)
  • Passed: 28,606 (97.27%)
  • Other: 802 (2.73%)
  • Total: 29,410
Code coverage

  • 6928 of 26802 lines covered (25.85%)

Annotations

Check failure on line 1 in test_cleanup_connections_scenarios[missing_attribute-\n class MinimalConnection:\n # No _closed attribute\n def close(self):\n pass\n \n # Register connection without _closed\n mock_conn = MinimalConnection()\n mssql_python._register_connection(mock_conn)\n \n # Should not crash\n mssql_python._cleanup_connections()\n -Missing attribute: PASSED]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / MSSQL-Python-PR-Validation

test_cleanup_connections_scenarios[missing_attribute-\n class MinimalConnection:\n # No _closed attribute\n def close(self):\n pass\n \n # Register connection without _closed\n mock_conn = MinimalConnection()\n mssql_python._register_connection(mock_conn)\n \n # Should not crash\n mssql_python._cleanup_connections()\n -Missing attribute: PASSED]

AssertionError: Test failed. stderr: 
assert -11 == 0
 +  where -11 = CompletedProcess(args=['/opt/venv/bin/python', '-c', '\nimport mssql_python\n\n# Verify cleanup infrastructure exists\nassert hasattr(mssql_python, \'_active_connections\'), "Missing _active_connections"\nassert hasattr(mssql_python, \'_cleanup_connections\'), "Missing _cleanup_connections"\nassert hasattr(mssql_python, \'_register_connection\'), "Missing _register_connection"\n\n\nclass MinimalConnection:\n    # No _closed attribute\n    def close(self):\n        pass\n\n# Register connection without _closed\nmock_conn = MinimalConnection()\nmssql_python._register_connection(mock_conn)\n\n# Should not crash\nmssql_python._cleanup_connections()\n\n\nprint("Missing attribute: PASSED")\n'], returncode=-11, stdout='', stderr='').returncode
Raw output
self = <test_013_SqlHandle_free_shutdown.TestHandleFreeShutdown object at 0x5503db9390>
conn_str = 'Server=172.17.0.4;Database=TestDB;Uid=SA;Pwd=Azure@123!;TrustServerCertificate=yes'
scenario = 'missing_attribute'
test_code = '\n            class MinimalConnection:\n                # No _closed attribute\n                def close(self):\n   ...conn)\n            \n            # Should not crash\n            mssql_python._cleanup_connections()\n                '
expected_msg = 'Missing attribute: PASSED'

    @pytest.mark.parametrize(
        "scenario,test_code,expected_msg",
        [
            (
                "normal_flow",
                """
            # Create mock connection to test registration and cleanup
            class MockConnection:
                def __init__(self):
                    self._closed = False
                    self.close_called = False
    
                def close(self):
                    self.close_called = True
                    self._closed = True
    
            # Register connection
            mock_conn = MockConnection()
            mssql_python._register_connection(mock_conn)
            assert mock_conn in mssql_python._active_connections, "Connection not registered"
    
            # Test cleanup
            mssql_python._cleanup_connections()
            assert mock_conn.close_called, "close() should have been called"
            assert mock_conn._closed, "Connection should be marked as closed"
                """,
                "Normal flow: PASSED",
            ),
            (
                "already_closed",
                """
            class MockConnection:
                def __init__(self):
                    self._closed = True  # Already closed
                    self.close_called = False
    
                def close(self):
                    self.close_called = True
                    raise AssertionError("close() should not be called on closed connection")
    
            # Register already-closed connection
            mock_conn = MockConnection()
            mssql_python._register_connection(mock_conn)
    
            # Cleanup should skip this connection
            mssql_python._cleanup_connections()
            assert not mock_conn.close_called, "close() should NOT have been called"
                """,
                "Already closed: PASSED",
            ),
            (
                "missing_attribute",
                """
            class MinimalConnection:
                # No _closed attribute
                def close(self):
                    pass
    
            # Register connection without _closed
            mock_conn = MinimalConnection()
            mssql_python._register_connection(mock_conn)
    
            # Should not crash
            mssql_python._cleanup_connections()
                """,
                "Missing attribute: PASSED",
            ),
            (
                "exception_handling",
                """
            class GoodConnection:
                def __init__(self):
                    self._closed = False
                    self.close_called = False
    
                def close(self):
                    self.close_called = True
                    self._closed = True
    
            class BadConnection:
                def __init__(self):
                    self._closed = False
    
                def close(self):
                    raise RuntimeError("Simulated error during close")
    
            # Register both good and bad connections
            good_conn = GoodConnection()
            bad_conn = BadConnection()
            mssql_python._register_connection(bad_conn)
            mssql_python._register_connection(good_conn)
    
            # Cleanup should handle exception and continue
            try:
                mssql_python._cleanup_connections()
                # Should not raise despite bad_conn throwing exception
                assert good_conn.close_called, "Good co

Check failure on line 1 in test_cleanup_connections_scenarios[exception_handling-\n class GoodConnection:\n def __init__(self):\n self._closed = False\n self.close_called = False\n \n def close(self):\n self.close_called = True\n self._closed = True\n \n class BadConnection:\n def __init__(self):\n self._closed = False\n \n

See this annotation in the file changed.

@azure-pipelines azure-pipelines / MSSQL-Python-PR-Validation

test_cleanup_connections_scenarios[exception_handling-\n class GoodConnection:\n def __init__(self):\n self._closed = False\n self.close_called = False\n \n def close(self):\n self.close_called = True\n self._closed = True\n \n class BadConnection:\n def __init__(self):\n self._closed = False\n \n

AssertionError: Test failed. stderr: 
assert -11 == 0
 +  where -11 = CompletedProcess(args=['/opt/venv/bin/python', '-c', '\nimport mssql_python\n\n# Verify cleanup infrastructure exists\nassert hasattr(mssql_python, \'_active_connections\'), "Missing _active_connections"\nassert hasattr(mssql_python, \'_cleanup_connections\'), "Missing _cleanup_connections"\nassert hasattr(mssql_python, \'_register_connection\'), "Missing _register_connection"\n\n\nclass GoodConnection:\n    def __init__(self):\n        self._closed = False\n        self.close_called = False\n\n    def close(self):\n        self.close_called = True\n        self._closed = True\n\nclass BadConnection:\n    def __init__(self):\n        self._closed = False\n\n    def close(self):\n        raise RuntimeError("Simulated error during close")\n\n# Register both good and bad connections\ngood_conn = GoodConnection()\nbad_conn = BadConnection()\nmssql_python._register_connection(bad_conn)\nmssql_python._register_connection(good_conn)\n\n# Cleanup should handle exception and continue\ntry:\n    mssql_python._cleanup_connections()\n    # Should not raise despite bad_conn throwing exception\n    assert good_conn.close_called, "Good connection should still be closed"\nexcept Exception as e:\n    print(f"Exception handling: FAILED - Exception escaped: {{e}}")\n    raise\n\n\nprint("Exception handling: PASSED")\n'], returncode=-11, stdout='', stderr='').returncode
Raw output
self = <test_013_SqlHandle_free_shutdown.TestHandleFreeShutdown object at 0x5503db9a10>
conn_str = 'Server=172.17.0.4;Database=TestDB;Uid=SA;Pwd=Azure@123!;TrustServerCertificate=yes'
scenario = 'exception_handling'
test_code = '\n            class GoodConnection:\n                def __init__(self):\n                    self._closed = False\n ...              print(f"Exception handling: FAILED - Exception escaped: {{e}}")\n                raise\n                '
expected_msg = 'Exception handling: PASSED'

    @pytest.mark.parametrize(
        "scenario,test_code,expected_msg",
        [
            (
                "normal_flow",
                """
            # Create mock connection to test registration and cleanup
            class MockConnection:
                def __init__(self):
                    self._closed = False
                    self.close_called = False
    
                def close(self):
                    self.close_called = True
                    self._closed = True
    
            # Register connection
            mock_conn = MockConnection()
            mssql_python._register_connection(mock_conn)
            assert mock_conn in mssql_python._active_connections, "Connection not registered"
    
            # Test cleanup
            mssql_python._cleanup_connections()
            assert mock_conn.close_called, "close() should have been called"
            assert mock_conn._closed, "Connection should be marked as closed"
                """,
                "Normal flow: PASSED",
            ),
            (
                "already_closed",
                """
            class MockConnection:
                def __init__(self):
                    self._closed = True  # Already closed
                    self.close_called = False
    
                def close(self):
                    self.close_called = True
                    raise AssertionError("close() should not be called on closed connection")
    
            # Register already-closed connection
            mock_conn = MockConnection()
            mssql_python._register_connection(mock_conn)
    
            # Cleanup should skip this connection
            mssql_python._cleanup_connections()
            assert not mock_conn.close_called, "close() should NOT have been called"
                """,
                "Already closed: PASSED",
            ),
            (
                "missing_attribute",
                """
            class MinimalConnection:
                # No _closed attribute
                def close(self):
                    pass
    
            # Register connection without _closed
            mock_conn = MinimalConnection()
            mssql_python._register_connection(mock_conn)
    
            # Should not crash
            mssql_python._cleanup_connections()
                """,
                "Missing attribute: PASSED",
            ),
            (
                "exception_handling",
                """
            class GoodConnection:
                def __init__(self):
                    self._closed = False
                    self.close_called = False
    
                def close(self):
                    self.close_called = True
                    self._closed = True
    
            class BadConnection:
                def __init__(self):
                    self._closed = False
    
                def close(self):
                    raise RuntimeError("Simulated error during close")
    
            # Register both good and bad connections
            good_conn = GoodConnection()
            bad_conn = BadConnection()
            mssql_python._register_connection(bad_conn)
            mssql_python._register_connection(good_conn)
    
            # Cleanup should handle exception and continue
            try:
                mssql_python._cleanup_connections()
                # Should not raise despite bad_conn throwing exception
                assert good_conn.close_called, "Good