fix: 查询页两个细节修复
1. 点击侧边栏表名插入 db.table 格式(如 log_analytics.access_logs)
- SchemaSidebar 表名: onInsert(t.name) → onInsert(`${dbName}.${t.name}`)
- SchemaSidebar 字段名: onInsert(col.Field) → onInsert(`${t.name}.${col.Field}`)
2. 查询不存在的表应显示错误而非'无结果数据'
- QueriesPage handleExecute: 检查 res.error 字段,有错误则 setError + 不设 result
This commit is contained in:
1 parent
9dda75efdb
commit
6b5d8bede4
2 files changed
+9
-4
No files matched your search
@@ -498,8 +498,8 @@ export default function SchemaSidebar({ instanceId, database, dbType, onInsert }
|
||||
<Table2 className="w-2.5 h-2.5 text-blue-400 flex-shrink-0" />
|
||||
<span
|
||||
className="font-mono truncate flex-1 text-left hover:text-blue-400 transition-colors"
|
||||
onClick={(e) => { e.stopPropagation(); onInsert(t.name); }}
|
||||
title="点击插入表名"
|
||||
onClick={(e) => { e.stopPropagation(); onInsert(`${dbName}.${t.name}`); }}
|
||||
title="点击插入 库名.表名"
|
||||
>
|
||||
{t.name}
|
||||
</span>
|
||||
@@ -519,7 +519,7 @@ export default function SchemaSidebar({ instanceId, database, dbType, onInsert }
|
||||
tableColumns.map(col => (
|
||||
<button
|
||||
key={col.Field}
|
||||
onClick={() => onInsert(col.Field)}
|
||||
onClick={() => onInsert(`${t.name}.${col.Field}`)}
|
||||
className="flex items-center gap-1.5 w-full px-2 py-0.5 text-[10px] hover:bg-[var(--dg-bg-hover)] transition-colors"
|
||||
title={`${col.Type} ${col.Null === 'NO' ? 'NOT NULL' : ''}`}
|
||||
>
|
||||
|
||||
@@ -210,7 +210,12 @@ export default function QueriesPage() {
|
||||
setExecuting(true); setError(''); setResult(null);
|
||||
try {
|
||||
const res = await queryApi.execute({ instance_id: Number(instanceId), database: database || undefined, sql }) as unknown as QueryResult;
|
||||
setResult(res);
|
||||
if (res.error) {
|
||||
setError(res.error);
|
||||
setResult(null);
|
||||
} else {
|
||||
setResult(res);
|
||||
}
|
||||
setHistory(prev => [{ id: Date.now(), sql, instance_id: Number(instanceId), database, db_type: dbType, status: 'success', execution_time_ms: res.execution_time_ms || 0, result_preview: JSON.stringify(res.rows?.[0] || {}).substring(0, 100), created_at: new Date().toISOString(), favorite: false }, ...prev]);
|
||||
} catch (e: unknown) {
|
||||
const raw = (e as { response?: { data?: { detail?: string | Array<{ msg: string }> } } })?.response?.data?.detail;
|
||||
|
||||
Reference in new issue
Block a user