AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Table Editor Shows The Wrong Row Count When Filtering Number Column By Zero

When filtering a numeric column by value 0 in Supabase Table Editor, the visible rows are filtered correctly but the row count still reflects the unfiltered table because the count query omits the filter due to a truthiness check on the converted value 0.

mediumConfidence 95%Supabase Studio

Origin Analysis

The filter application logic converts the input string "0" to the number 0 using Number(), and then checks the value's truthiness (e.g., `if (convertedValue)`) before adding the filter to the query. Since 0 is falsy, the filter is skipped for the count query while the row query uses the raw string for filtering, leading to inconsistent counts.
1. Open a table with a numeric column containing zero and non-zero values. 2. Add an 'equals' filter for that column. 3. Enter 0 and apply the filter. 4. Observe that the visible rows are filtered but the row count still shows the total number of rows.

Fixing Code Block

export const applyTableFilter = (query: any, filter: any) => { const rawValue = filter.value; // Ignore only truly empty values, not zero if (rawValue === null || rawValue === undefined || rawValue === '') { return query; } const numericValue = Number(rawValue); if (Number.isNaN(numericValue)) { return query; } return query.eq(filter.column, numericValue); };
The fix replaces the truthiness check with an explicit check for null, undefined, and empty string before converting the value to a number. This ensures that a valid numeric zero is not mistaken for an empty filter, while still ignoring truly blank inputs. The conversion is then applied and the filter is added using query.eq(). This function should be used consistently for both the data query and the count query to keep them in sync.

Edge Case Audit

If the original filter application logic had other places relying on truthiness (e.g., for boolean filters or non-numeric columns), this change may alter behavior. Ensure that all filter types (text, boolean, date) are handled appropriately; for non-numeric filters, the conversion to Number should not be applied. The fix assumes query.eq() is the correct method for equality filters in the Supabase client; verify that the column name is properly escaped and that the query builder supports chaining. Rollback: revert to the previous truthiness check if this causes unexpected filter application for other falsy values like empty arrays or false boolean, but for numeric zero the fix is correct.

Ecosystem Topology