🐛 fix(query-editor): 修复 Oracle 序列查询自动限行报错

- 识别可执行 SQL 中的 NEXTVAL 与 CURRVAL 序列伪列
- Oracle、达梦及 OceanBase Oracle 序列查询跳过 ROWNUM 子查询包装
- 排除字符串和注释中的同名文本误判
- 补充自动限行与真实执行链路回归测试
This commit is contained in:
Syngnat
2026-07-13 12:54:43 +08:00
parent 4bee3cefa6
commit b23e768973
3 changed files with 122 additions and 0 deletions

View File

@@ -8423,6 +8423,37 @@ describe('QueryEditor external SQL save', () => {
renderer?.unmount();
});
it('keeps OceanBase Oracle sequence queries out of the ROWNUM auto-limit wrapper', async () => {
const sql = 'SELECT IMP_BASICINFO.SEQ_HIS_AZA7.nextval FROM dual';
storeState.connections[0].config.type = 'oceanbase';
(storeState.connections[0].config as any).oceanBaseProtocol = 'oracle';
storeState.connections[0].config.database = 'ORCLPDB1';
backendApp.DBQueryMulti.mockResolvedValueOnce({
success: true,
data: [{ columns: ['NEXTVAL'], rows: [{ NEXTVAL: 42 }] }],
});
let renderer!: ReactTestRenderer;
await act(async () => {
renderer = create(<QueryEditor tab={createTab({ dbName: 'IMP_BASICINFO', query: sql })} />);
});
await act(async () => {
await findButton(renderer!, '运行').props.onClick();
});
await act(async () => {
await Promise.resolve();
await Promise.resolve();
});
const executedSql = String(backendApp.DBQueryMulti.mock.calls[0][2]);
expect(executedSql).toContain('IMP_BASICINFO.SEQ_HIS_AZA7.nextval');
expect(executedSql).not.toContain('SELECT * FROM (');
expect(executedSql).not.toMatch(/\bROWNUM\b/i);
expect(backendApp.DBQueryMultiTransactional).not.toHaveBeenCalled();
renderer?.unmount();
});
it('quotes exact-case OceanBase Oracle lowercase tables for execution while keeping sql logs unchanged', async () => {
storeState.connections[0].config.type = 'oceanbase';
(storeState.connections[0].config as any).oceanBaseProtocol = 'oracle';