Repository navigation
Todo
Labels
enhancementNew feature or request
Description
Is your feature request related to a problem? Please describe.
- Apps that build on Tables today put JSON into text columns and parse it themselves. On Grid pages in applications (frontend) #3099 blizzz advised to store JSON as text in the database, not in the database JSON type, and to give data that may be queried its own column. This type follows that advice: the cell is stored as text, and the column is never offered for filter, sort, search or aggregation (proposal P3).
Why this is needed
- Apps that build on Tables keep structured values next to a row: imported structures, display data, configuration. Today they put JSON in a text column, and every client parses and checks it on its own. Nothing on the server knows the cell holds JSON.
- buildiq parity: OpenRegister schemas have object properties. The JSON Schema export and import (JSON Schema import/export #3130) needs a column type to map such a property to without flattening it into columns.
- Plan: part of M1 data foundation ("json, file and array column types"), which is not deferrable past the freeze. The column
format(Formats as subtypes, validated by format definitions #3128) builds on it (a json column with formatgeojson), and the map widget (Map widget #3446) can read its coordinates from such a column.
Describe the solution you'd like
- A column type that holds a JSON value per cell: a dictionary, a list, or a scalar. It is for display data, imported structures and configuration that apps want to keep next to a row without modelling every key as a column.
Diagram
erDiagram
tables_tables ||--o{ tables_columns : has
tables_tables ||--o{ tables_row_sleeves : has
tables_row_sleeves ||--o{ json_cell : holds
tables_columns ||--o{ json_cell : types
tables_columns {
string type "json"
string format "optional, for example geojson (#3128)"
json customSettings "optional JSON Schema fragment"
}
json_cell {
int row_id
int column_id
text value "JSON as text, never filtered, sorted or searched"
}
Acceptance Criteria
- A json column can be created, updated and deleted on
api/1andapi/2, and appears in the OpenAPI document. - A cell value is validated as JSON on write; invalid JSON answers 400.
- An optional JSON Schema fragment in the column settings validates the value on write.
- The column does not appear in the filter, sort and search options of a view.
- Import and export of a table carry the column and its values.
- The cell editor shows the value as formatted JSON and accepts edits.
- Unit tests for the validation, a Playwright spec for create, edit and export.
- The value is stored as JSON text in a text cell, never in the database JSON column type, as advised on Grid pages in applications (frontend) #3099. A value that must be filtered or sorted on gets its own column of a queryable type.
- The route declares its permission with
#[RequirePermission]using a fixed node type, and the service checks the same right before it writes. A test runs every write as a reader and expects 403 (or 404 where the reader may not know the object exists), as learned in the review of feat(contexts): give applications a menu with its own API #3135. - Deleting a row or the column removes its json cells in the same transaction, as rows and columns do for every cell type today.
- If the cells get their own table, the migration creates it and bumps the version in
appinfo/info.xml; no index on the value, because it is never queried (P3). The CSV import timing of the benchmark (Benchmark the rows API on a table of 100k rows #3424) is run before and after. - The cell editor uses
NcTextAreafrom nc-vue. - Usable at 360 px wide: nothing cut off and no horizontal scroll of the page. Every action works with the keyboard alone.
Out of scope
- Filter, sort, search, facets and aggregation on json cells: never, by proposal P3.
- The
geojsonformat: part of the formats work (Formats as subtypes, validated by format definitions #3128). - Reading coordinates for the map widget: Map widget #3446.
- A form generated from the JSON Schema fragment: later, if asked for.
- Slicing, in landing order: one PR for the type on the server (storage, validation,
api/2, OpenAPI, import and export), then one PR for the cell editor and renderer.
Describe alternatives you've considered
Questions for maintainers
- Where are the cells stored? Options: (a) in the existing text cell table
tables_row_cells_text, marked by the column type, (b) in a new cell table for json. We would go with (a): no new table and no migration. If the text cell indexes of Add Cell value indices #3249 make large JSON values slow to write, the benchmark shows it and we move to (b). - Does the first PR validate against a JSON Schema fragment? Options: (a) yes, with a validator library added to Tables, (b) the first PR only checks that the value parses as JSON, the schema fragment follows in its own PR. We would go with (b), to keep the first PR to one behaviour.
- Is there a size limit per cell? Options: (a) a fixed limit, like the 60000 bytes of widget settings (
GridWidgetTypes::SETTINGS_MAX_BYTES), (b) an admin setting. We would go with (a): one rule that the API documents.
Additional context
Linking to other objects
- Object: a column and its cells. The value is opaque text to Tables.
- Today: the relation column (
RelationBusiness.php) and the link column (TextLinkBusiness.php) are the only cells that point at something else. Neither looks into JSON, and nothing else does. - What this issue must do: keep links out of the JSON value. An id of a row, file or object inside a json cell is not a link: it is not checked for access, not cleaned up on delete and not remapped on import. Links go through a relation column or the link store of Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468. The documentation says so, and export and import carry the value unchanged.
Relevant files:
Related issues
- Grid pages in applications (frontend) #3099
- Formats as subtypes, validated by format definitions #3128
Drafted with AI assistance from the project plan; @remko48 reviews it. Part of #3419.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity