🐛 fix(sql-editor): 移除对象信息未命中误报提示

- 取消对象信息未命中时的提示弹窗
- 保留已识别对象的 hover 与超链接行为
- 补充未命中静默回归测试
This commit is contained in:
Syngnat
2026-06-07 12:12:02 +08:00
parent a5b27820cb
commit ace6e18da8
2 changed files with 30 additions and 7 deletions

View File

@@ -983,6 +983,35 @@ describe('QueryEditor external SQL save', () => {
}));
});
it('keeps ctrl+q object info silent when no object is recognized', async () => {
editorState.value = 'select 1';
autoFetchState.visible = true;
backendApp.DBGetDatabases.mockResolvedValueOnce({ success: true, data: [{ Database: 'main' }] });
backendApp.DBGetTables.mockResolvedValueOnce({ success: true, data: [{ Tables_in_main: 'users' }] });
backendApp.DBGetAllColumns.mockResolvedValueOnce({ success: true, data: [] });
await act(async () => {
create(<QueryEditor tab={createTab({ query: editorState.value, dbName: 'main' })} />);
});
await act(async () => {
await Promise.resolve();
await Promise.resolve();
});
const showObjectInfoAction = editorState.editor.addAction.mock.calls
.map((call: any[]) => call[0])
.find((action: any) => action?.id === 'gonavi.queryEditor.showObjectInfo');
expect(showObjectInfoAction).toBeTruthy();
editorState.position = { lineNumber: 1, column: 1 };
await act(async () => {
showObjectInfoAction.run();
});
expect(editorState.contentHoverCalls).toHaveLength(0);
expect(messageApi.info).not.toHaveBeenCalled();
});
it('adds separate object and column color decorations', async () => {
editorState.value = 'select users.id from users';
autoFetchState.visible = true;

View File

@@ -2820,13 +2820,7 @@ const QueryEditor: React.FC<{ tab: TabData; isActive?: boolean }> = ({ tab, isAc
keybindings: showObjectInfoKeybinding,
run: () => {
const preferredPosition = lastHoverTargetPositionRef.current || editor.getPosition?.();
const shown = showObjectInfoAtPosition(preferredPosition);
if (!shown) {
void message.info({
key: 'gonavi-query-editor-object-info-miss',
content: '当前光标未定位到可识别的表或字段。',
});
}
showObjectInfoAtPosition(preferredPosition);
},
});