fix: cover MUTATE_AFTER_SPLIT branches, guard empty/mismatched mutated statements

Add missing coverage for the MUTATE_AFTER_SPLIT=True branch, add type
hints to satisfy dev-standard lint, and guard against a SQL_QUERY_MUTATOR
that strips all statements or changes statement count when mutating
before the split.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Evan
2026-07-12 09:21:59 -07:00
parent c6bf4e65b6
commit ef1ec529bc
6 changed files with 201 additions and 8 deletions

View File

@@ -94,6 +94,10 @@ def mock_database() -> MagicMock:
database.db_engine_spec.get_cancel_query_id = MagicMock(return_value=None)
database.db_engine_spec.patch = MagicMock()
database.db_engine_spec.fetch_data = MagicMock(return_value=[])
# Mirrors the real `Database.mutate_sql_based_on_config` default (no-op
# when no `SQL_QUERY_MUTATOR` is configured), so SQL parsed from its
# return value stays valid instead of an un-parseable `MagicMock`.
database.mutate_sql_based_on_config = MagicMock(side_effect=lambda sql, **kw: sql)
return database