mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-21 02:41:59 +00:00
M4:双盲复算「规范化后不同的行」每个条件一行,两边相同的条件不再被标成差异
验收时审批卡把两边完全相同的日期区间标成了差异:_text_diff 逐行比两边 sqlglot pretty 的输出,pretty 按宽度决定 换不换行,两个合取的 WHERE 排成一行、三个的拆成三行,同一个条件在两边落在不同的行上。原文 SQL 都是单行时原文栏 一行都不标,这一栏是唯一逐行指出差在哪的地方,审核人会以为统计期也不一样。 现在逐行比之前两边按同一套排版写(_diff_lines / _line_generator,按方言给 sqlglot 的生成器加一处改动):WHERE、 HAVING、ON 的合取式每个条件一行,各层子查询里的也一样;条件本身是 OR 连起来的一律加括号(单独一个和与别的并列时 写法一样);ON 照 WHERE 的样子单独一行、条件缩进在下面(ON 里和 WHERE 里的同一个条件不当成同一行)。比的时候 不看条件前面的 AND(一边多出来的条件排在最前面时,另一边同一个条件只差在有没有 AND),列出来的仍是各自原样的行。 只动排版:判不判等价、差异说明不变(拿测试里的 SQL 对照语料按三种方言、有无表结构逐对比过,items、equivalent、 fallback、level 全部一致),sql_semantics、sql_equivalence 原有测试全过。 前端夹具 dual_check.json 里的 text_diff 是服务端的真实输出,按 test_dual_check_fixture 的办法重新生成(只变了 text_diff);check-verify 的对照行一节另查「只差结束日期时开始日期不标」「多出的两个条件各占一行」。
This commit is contained in:
@@ -297,7 +297,7 @@ await section('审批卡:并排对照与高亮(服务端真实的差异输
|
||||
const blind = gmv.locator('[data-dual-sql="blind"]')
|
||||
check('两条 SQL 都在,各标是哪一边', (await text(orig)).includes('paid_at') && (await text(blind)).includes('created_at')
|
||||
&& (await text(gmv.locator('[data-dual-pair]'))).includes('原流程的 SQL') && (await text(gmv.locator('[data-dual-pair]'))).includes('盲算的 SQL'))
|
||||
// 夹具的 text_diff 是 explain_sql_diff 的真实输出:规范化后列名带表名、两个条件并成一行,和原文的任何一行都对不上
|
||||
// 夹具的 text_diff 是 explain_sql_diff 的真实输出:规范化后列名带表名、每个条件一行,和原文的任何一行都对不上
|
||||
const real = sidesOf(fx.card.metrics[0].diff)
|
||||
const rawLines = new Set(fx.card.metrics[0].original.inputs[0].sql.split('\n').map((l) => l.trim()))
|
||||
check('(夹具)text_diff 是规范化后的行,和原文逐行对不上', real.del.length > 0 && !real.del.some((l) => rawLines.has(l)), real.del.join(' | '))
|
||||
@@ -462,6 +462,18 @@ await section('审批卡:没有预告时,「记入数据目录」只说必
|
||||
if (!real.add.length) {
|
||||
check('……一边没有不同的行时照实说', (await text(gmv.locator('[data-dual-norm="blind"]'))).includes('没有不同的行'))
|
||||
}
|
||||
// 规范化后每个条件一行(2026-10 验收:两个条件排在一行、三个拆成三行,两边相同的日期条件因为换行的位置不同被
|
||||
// 标成了差异)。只差结束日期时,两边一样的开始日期不标,只标结束日期那一行
|
||||
if (name === 'fallback') {
|
||||
const marked = [...m.normDel, ...m.normAdd]
|
||||
check('……两边相同的条件(开始日期)不标,只标不同的那一行', m.normDel.length === 1 && m.normAdd.length === 1
|
||||
&& !marked.some((l) => l.includes(">= '2026-09-01'"))
|
||||
&& marked.every((l) => l.includes("orders.paid_at < '2026-09-")), marked.join(' ‖ '))
|
||||
}
|
||||
if (name === 'two_filters') {
|
||||
check('……一边多出的两个条件各占一行', m.normDel.includes("orders.channel = 'web'")
|
||||
&& m.normDel.includes("AND orders.status <> 'refunded'"), m.normDel.join(' | '))
|
||||
}
|
||||
}
|
||||
check(`${what}:页面没有报错`, errors.length === 0, errors.join(';'))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user