mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## What Follow-up to #52952. The grid truncates large columns (over 10 KB) in the database query, so \"Duplicate row\" used to leave those fields blank. It now fetches their full values and fills them into the Insert Row panel. ## Behavior - Truncated columns are fetched by primary key after the panel opens. Each one is disabled with \"Loading full value...\" until it arrives, and Save is disabled until every value has settled. Submitting the form another way (e.g. pressing Enter) is blocked too. - Only the truncated fields are filled in, so anything the user has edited is never overwritten. - If a value can't be copied, the field stays empty with a note saying why: - the value is over 1 MB (it isn't sent, so a single row can't pull an unbounded amount of data into the browser) - the table has no primary key - the fetch failed (also shows a toast) - The fetch honors \"View as role\", like the existing \"Load full\" buttons. ## How - New `useRowLargeValuesQuery` in `data/table-rows/` selects the truncated columns of one row in a single query. Each column is returned as `NULL` when it exceeds `MAX_ROW_LARGE_VALUE_BYTES`. The SQL is built with `ident()`, `literal()` and the Query builder. - A new `useCopiedLargeValues` hook owns the fetch and per-field status, to keep `RowEditor` from growing further. Pure helpers (`getTruncatedFieldNames`, `getPrimaryKeyMatch`, `mergeLargeValues`) are in `RowEditor.utils.ts`. - `InputField` takes an optional `status` and renders the note. ## Also changes `isValueTruncated` now compares byte length instead of character length. The query truncates when a value exceeds the limit in bytes but cuts by characters, so a value of multibyte characters could be truncated and still be shorter than the limit in characters, and wasn't detected. Comparing bytes still never flags a genuine value, because an untruncated value is at most the limit in bytes. Edit row's \"Load full\" buttons benefit from the same fix. ## Notes - A fetched value over 10 KB that genuinely ends in `...` still looks truncated to the existing check, so the form disables that field, as it already does when editing such a row. - A column that changed to `NULL` after the grid loaded also shows the \"too large\" note. ## Testing - Unit tests for the SQL builder (including identifier and literal escaping), the byte-aware detection, and the new helpers. - Component tests for `RowEditor`: the full value is fetched and included in the insert; field and Save are disabled while loading (including form submit); too large, fetch failure, and no primary key leave the field empty with a note; nothing is fetched when no value was truncated. I confirmed the loading test fails when the Save guard is removed. Resolves FE-4927
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
export const tableRowKeys = {
|
|
tableRows: (projectRef?: string, { table, roleImpersonationState, ...args }: any = {}) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'table-rows',
|
|
table?.id,
|
|
'rows',
|
|
{ roleImpersonation: roleImpersonationState?.role, ...args },
|
|
] as const,
|
|
rowLargeValues: (
|
|
projectRef?: string,
|
|
{
|
|
table,
|
|
columns,
|
|
pkMatch,
|
|
roleImpersonationState,
|
|
}: {
|
|
table?: { schema: string; name: string }
|
|
columns?: string[]
|
|
pkMatch?: object
|
|
roleImpersonationState?: { role?: unknown }
|
|
} = {}
|
|
) =>
|
|
[
|
|
'projects',
|
|
projectRef,
|
|
'table-rows',
|
|
table?.schema,
|
|
table?.name,
|
|
'row-large-values',
|
|
{ columns, pkMatch, roleImpersonation: roleImpersonationState?.role },
|
|
] as const,
|
|
tableRowsCount: (projectRef?: string, { table, ...args }: any = {}) =>
|
|
['projects', projectRef, 'table-rows', table?.id, 'count', args] as const,
|
|
tableRowsAndCount: (projectRef?: string, tableId?: number) =>
|
|
['projects', projectRef, 'table-rows', tableId] as const,
|
|
}
|