fix: SQL Explorer handles comments and shows descriptive errors

- Strip SQL comments (-- and /* */) before checking for SELECT,
  so queries with leading comments don't get rejected
- Show the actual error detail from the API response instead of
  generic 'API error 400' in the SQL Explorer UI
This commit is contained in:
Celes Renata
2026-04-16 05:25:45 +00:00
parent d28787a8ee
commit 1107d34027
2 changed files with 11 additions and 2 deletions
+5 -1
View File
@@ -53,7 +53,11 @@ export function SqlExplorerPage() {
const executeMutation = useMutation({
mutationFn: (sqlText: string) => apiPost<QueryResult>('query', '/api/analytics/pg-query', { sql: sqlText, limit: 1000 }),
onSuccess: (data) => { setResult(data); setError(null); },
onError: (err: Error) => { setError(err.message); setResult(null); },
onError: (err: Error) => {
const detail = (err as { body?: { detail?: string } }).body?.detail;
setError(detail || err.message);
setResult(null);
},
});
const saveMutation = useMutation({