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:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user