🐛 fix(query-editor): 修正 SQL 编辑器 DML 事务识别

- 统一前后端 DML 与数据修改 CTE 的受管事务判断

- 保留数据修改 CTE 返回行并补充事务回归测试

- 明确 SQL 编辑器事务提交策略文案
This commit is contained in:
Syngnat
2026-06-10 19:13:54 +08:00
parent cf8f9be8dc
commit 89639e36bc
9 changed files with 206 additions and 37 deletions

View File

@@ -27,6 +27,12 @@ describe('sqlEditorTransaction', () => {
])).toBe(false);
});
it('uses managed transactions for data-changing CTEs even when the top-level operation is SELECT', () => {
const sql = 'WITH moved AS (DELETE FROM audit_logs WHERE created_at < NOW() RETURNING id) SELECT * FROM moved';
expect(resolveSqlEditorOperationKeyword(sql)).toBe('select');
expect(shouldUseSqlEditorManagedTransaction([sql])).toBe(true);
});
it('does not wrap user-authored explicit transactions', () => {
expect(shouldUseSqlEditorManagedTransaction([
'BEGIN',