SQL Editor Misleadingly Shows '0 Rows' For UPDATE/DELETE Statements
The SQL Editor's results panel displays '0 rows' and 'Success. No rows returned.' after executing UPDATE or DELETE statements that affect rows but do not return them, because it only inspects the length of the returned rows array and ignores PostgreSQL's command tag and row count.
UtilityTabResults.tsx branches solely on whether the returned row array is empty, treating all statements like SELECT queries. The /platform/pg-meta/{ref}/query endpoint currently returns only `rows` and discards the PostgreSQL result metadata (`command` and `rowCount`), so the frontend cannot distinguish between a SELECT that returned no rows and an UPDATE/DELETE that modified rows but returned none.
1. Open SQL Editor on a project with a table containing at least one row.
2. Run: UPDATE position_log SET notes = notes WHERE id = (SELECT id FROM position_log LIMIT 1);
3. Observe results panel shows '0 rows' and 'Success. No rows returned.' although one row was updated.
Fixing Code Block
// In UtilityTabResults.tsx, add this helper before the component
const NON_SELECT_SQL_REGEX = /^\s*(update|delete|insert|alter|create|drop|truncate|grant|revoke|set|reset)\b/i;
// Inside the component, replace the empty results branch with:
if (!result || result.length === 0) {
const isNonSelect = NON_SELECT_SQL_REGEX.test(query);
return <p>{isNonSelect ? 'Success. Query executed.' : 'Success. No rows returned.'}</p>;
}
The regex detects common SQL commands that do not return rows (UPDATE, DELETE, INSERT, DDL, etc.). When such commands succeed but the result array is empty, the UI now shows 'Success. Query executed.' instead of the misleading '0 rows' and 'Success. No rows returned.', which only makes sense for SELECT-like statements.
Edge Case Audit
This hotfix does not surface the actual affected-row count; it only removes the misleading '0 rows' text. A complete fix requires the backend to include `command` and `rowCount` from the PostgreSQL result and the frontend to display them. The regex may misclassify SQL that begins with a comment or a CTE containing a DML command, leading to the old message in such edge cases. Rollback is straightforward: revert the component to the previous empty-state rendering.