mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Context Resolves https://github.com/supabase/supabase/issues/51827 Filtering a high-precision numeric column (e.g. `numeric(30,21)`) showed the matching row, but the footer count said 0. We're currently using `formatFilterValue` which coerced numeric filter values with `Number()`, and rounds past ~15 digits so the generated = no longer matched the stored value. This same coercion was used by the count query, export (`getAllTableRowsSql`) and delete-all but the main rows query (`table-row-query`) never coerced, which is why rows and count disagreed. ## Changes involved - Given that `formatFilterValue` was legacy logic, opting to remove the coercion and consistently use `formatPatternMatchFilterValue` instead for all row operations as per what `table-row-query` uses, so filter values reach Postgres as exact string literals. ## To test - Run the following SQL statements to set up the table - `CREATE TABLE public.precise_values (amount numeric(30, 21));` - `INSERT INTO public.precise_values VALUES (0.123456789012345678901);` - In the Table Editor, filter amount = 0.123456789012345678901. The footer should show 1 record and should match what's rendered in the table
22 lines
642 B
TypeScript
22 lines
642 B
TypeScript
import type { ServiceError } from '@/components/grid/types'
|
|
import { Entity, isTableLike } from '@/data/table-editor/table-editor-types'
|
|
|
|
export function getPrimaryKeys({ table }: { table: Entity }): {
|
|
primaryKeys?: string[]
|
|
error?: ServiceError
|
|
} {
|
|
if (!isTableLike(table)) {
|
|
return {
|
|
error: { message: 'Only table rows can be updated or deleted' },
|
|
}
|
|
}
|
|
|
|
const pkColumns = table.primary_keys
|
|
if (!pkColumns || pkColumns.length == 0) {
|
|
return {
|
|
error: { message: 'Please add a primary key column to your table to update or delete rows' },
|
|
}
|
|
}
|
|
return { primaryKeys: pkColumns.map((x) => x.name) }
|
|
}
|