Skip to content

Bug: mssql_python execute_stack raises _connection_in_transaction NotImplementedError #572

Description

@cofin

Summary

mssql_python fails when executing a StatementStack through SQLSpec execute_stack().

While adding SQL Server coverage in Litestar Queues, a stale-recovery path that batches several UPDATE statements into a StatementStack failed for the SQLSpec mssql_python adapter with:

NotImplementedError: Adapters must override _connection_in_transaction()

Environment

  • sqlspec==0.52.0
  • mssql-python==1.10.0
  • pymssql==2.3.13
  • Python 3.14.4
  • SQL Server 2022 via pytest-databases (mcr.microsoft.com/mssql/server:2022-latest)

Reproduction Shape

The queue backend builds a StatementStack of UPDATE statements and calls:

stack = StatementStack()
for statement in statements:
    stack = stack.push_execute(statement)
await driver.execute_stack(stack)

Against mssql_python, this raises from SQLSpec internals:

sqlspec/driver/_async.py:1453: in execute_stack
sqlspec/driver/_async.py:1675: in _connection_in_transaction
NotImplementedError: Adapters must override _connection_in_transaction()

A local workaround is to avoid execute_stack() for SQL Server and execute the statements one-by-one in a transaction/session. That works for the queue backend contract.

Expected

mssql_python should either support execute_stack() or provide the transaction-state hook required by SQLSpec stack execution.

Actual

execute_stack() raises NotImplementedError before applying the batch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions