Trace write SQL queries in addition to read ones, closes #1568

This commit is contained in:
Simon Willison 2021-12-17 18:42:29 -08:00
commit f81d9d0cd9
2 changed files with 16 additions and 1 deletions

View file

@ -939,6 +939,19 @@ def test_trace(trace_debug):
assert isinstance(trace["sql"], str)
assert isinstance(trace["params"], (list, dict, None.__class__))
sqls = [trace["sql"] for trace in trace_info["traces"] if "sql" in trace]
# There should be a mix of different types of SQL statement
expected = (
"CREATE TABLE ",
"PRAGMA ",
"INSERT OR REPLACE INTO ",
"DELETE FROM ",
"INSERT INTO",
"select ",
)
for prefix in expected:
assert any(sql.startswith(prefix) for sql in sqls)
@pytest.mark.parametrize(
"path,status_code",