Files
Joshen Lim 7a9565530c Fix handle truncation for multi dim array for table-row-query (#51834)
## Context

If you create a table with a `jsonb` **array** column, then try to
insert a new row with `[["` as the `jsonb` column value, the dashboard
currently incorrectly flags it as a large value and blocks the user from
editing it

<img width="583" height="133" alt="image"
src="https://github.com/user-attachments/assets/28b89648-12b6-4b49-a862-b4ec0db03e24"
/>

It's happening due to a small issue in `table-row-query` regarding its
truncation logic, a stop gap to prevent fetching large column values
which will cause browser performance issues. Multi dimension arrays are
being handled differently in which there's no `...` appended at the end.
And hence the naive check in `isValueTruncated` caused this issue to
happen.

Opting to adjust the SQL in `table-row-query` to align the truncation
behaviour for multi dim array, such that it will end with `...` if the
value being fetched is too large.

## To test

We mainly need to ensure that the original problem no longer happens +
truncation of large values is still working as expected. The following
SQL here sets up some sample rows to test the truncation logic in the
UI.

```
create table trunc_test (
  id int primary key,
  label text,
  big_text text,
  big_json jsonb,
  big_text_1d text[],
  big_grid text[][],
  big_docs jsonb[][],
  small_grid text[][],
  small_docs jsonb[]
);

insert into trunc_test values
  -- row 1: everything large
  (1, 'large', repeat('a', 20000),
   jsonb_build_object('k', repeat('b', 20000)),
   (select array_agg(repeat('c', 300)) from generate_series(1, 120)),
   (select array_agg(array[repeat('d', 300), 'x']) from generate_series(1, 120)),
   (select array_agg(array['{"k":1}'::jsonb, to_jsonb(repeat('e', 300))]) from generate_series(1, 120)),
   array[array['a','b'], array['c','d']],
   array['["x"]'::jsonb]),
  -- row 2: everything small
  (2, 'small', 'hi', '{"k":1}', array['a'], array[array['a','b'], array['c','d']],
   array[array['{"k":1}'::jsonb]], array[array['a','b'], array['c','d']], array['["x"]'::jsonb]);
```
2026-10-19 17:03:11 +08:00
..