Add context menu option to set cell to default value #1361
Open
Description
Current behavior
-
Some columns may have dynamic default values defined in Postgres, for example to set a timestamp to the current time, or to set a number to a random value.
-
The user is able to set a cell to the default value when adding a new record, but not after the record exists.
Desired behavior
- The cell context menu (which already contains an option to set the cell to
NULL
) contains an option to set the cell toDEFAULT
. The menu entry also displays the Postgres expression to which the default value is defined.
Implementation
-
If we want this feature, we need to decide how to convey
DEFAULT
across the records API.Currently to PATCH column id 100 with a new value of "foo", we send:
{ "100": "foo" }
How would we PATCH that column with a value of
DEFAULT
? -
My inclination would be to use a schema like this:
{ "100": { "default": true } }
This potential feature and implementation is one reason that in Improve handling of non-Mathesar JSON types #1324 I suggested we add an additional layer of nesting if we do want to send JSON data as raw JSON in the API.