Skip to content

Commit c4d52e6

Browse files
committed
fix: enhance logging filter to cover additional sqlglot loggers and silence MySQL notes during fixture cleanup
1 parent 503d94f commit c4d52e6

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

sqlspec/utils/logging.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def suppress_erroneous_sqlglot_log_messages() -> None:
166166
about falling back to parsing as a Command. This is expected behavior
167167
in SQLSpec and the warning is confusing to users.
168168
"""
169-
sqlglot_logger = logging.getLogger("sqlglot")
170-
if not any(isinstance(f, SqlglotCommandFallbackFilter) for f in sqlglot_logger.filters):
171-
sqlglot_logger.addFilter(SqlglotCommandFallbackFilter())
169+
for logger_name in ("sqlglot", "sqlglot.scope", "sqlglot.generator"):
170+
sqlglot_logger = logging.getLogger(logger_name)
171+
if not any(isinstance(f, SqlglotCommandFallbackFilter) for f in sqlglot_logger.filters):
172+
sqlglot_logger.addFilter(SqlglotCommandFallbackFilter())

tests/integration/test_adapters/test_asyncmy/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ async def asyncmy_driver(asyncmy_config: AsyncmyConfig) -> AsyncGenerator[Asyncm
3737
async def asyncmy_clean_driver(asyncmy_config: AsyncmyConfig) -> AsyncGenerator[AsyncmyDriver, None]:
3838
"""Create AsyncMy driver with clean database state."""
3939
async with asyncmy_config.provide_session() as driver:
40+
# Silence MySQL "unknown table" notes during fixture cleanup to avoid noisy logs
41+
await driver.execute("SET sql_notes = 0")
4042
# Clean up any test tables that might exist
4143
cleanup_tables = [
4244
"test_table",
@@ -66,11 +68,17 @@ async def asyncmy_clean_driver(asyncmy_config: AsyncmyConfig) -> AsyncGenerator[
6668
for proc in cleanup_procedures:
6769
await driver.execute_script(f"DROP PROCEDURE IF EXISTS {proc}")
6870

71+
await driver.execute("SET sql_notes = 1")
72+
6973
yield driver
7074

75+
await driver.execute("SET sql_notes = 0")
76+
7177
# Cleanup after test
7278
for table in cleanup_tables:
7379
await driver.execute_script(f"DROP TABLE IF EXISTS {table}")
7480

7581
for proc in cleanup_procedures:
7682
await driver.execute_script(f"DROP PROCEDURE IF EXISTS {proc}")
83+
84+
await driver.execute("SET sql_notes = 1")

tests/integration/test_adapters/test_asyncmy/test_asyncmy_features.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,10 @@ async def test_asyncmy_sql_object_advanced_features(asyncmy_pooled_session: Asyn
257257
"""
258258
INSERT INTO advanced_test (name, metadata, score)
259259
VALUES (?, ?, ?)
260+
AS new_vals
260261
ON DUPLICATE KEY UPDATE
261-
score = VALUES(score) + ?,
262-
metadata = JSON_MERGE_PATCH(metadata, VALUES(metadata))
262+
score = new_vals.score + ?,
263+
metadata = JSON_MERGE_PATCH(metadata, new_vals.metadata)
263264
""",
264265
"complex_test",
265266
'{"type": "advanced", "priority": 1}',

0 commit comments

Comments
 (0)