From 90531720bb63f81b544cd95184c61b40cd24f9f7 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Fri, 3 Jul 2026 01:10:04 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20build=5Fdisplay=20modify=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E8=A1=A5=E9=BD=90=E8=A2=AB=20DROP=20=E7=9A=84?= =?UTF-8?q?=E8=A1=A8=E6=9D=A1=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 标准答案 DROP 表后该表不在 sqlite_master 中,changed_tables 会静默 遗漏;用初始展示数据补齐并标记 dropped=True。 Co-Authored-By: Claude Fable 5 --- judge/sql_runner.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/judge/sql_runner.py b/judge/sql_runner.py index cd51e26..14ad7be 100644 --- a/judge/sql_runner.py +++ b/judge/sql_runner.py @@ -324,7 +324,13 @@ def build_display(init_sql, ref_sql, mode, *, memory_limit_mb=64): _execute_trusted(conn, ref_sql, time.monotonic() + trusted_limit_s, "标准答案执行失败") after = _dump_tables(conn) changed = {name for name in set(before) | set(after) if before.get(name) != after.get(name)} - expected = {"changed_tables": _dump_display_tables(conn, only=changed)} + changed_tables = _dump_display_tables(conn, only=changed) + # 被标准答案 DROP 的表已不在库中,用初始展示数据补齐条目(前端据 dropped 提示“表已删除”) + existing = {t["name"] for t in changed_tables} + for t in tables: + if t["name"] in changed and t["name"] not in existing: + changed_tables.append({"name": t["name"], "columns": t["columns"], "rows": [], "total_rows": 0, "truncated": False, "dropped": True}) + expected = {"changed_tables": changed_tables} return {"tables": tables, "expected": expected} finally: conn.close()