Skip to content

Add context menu option to set cell to default value #1361

@seancolsen

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 to DEFAULT. 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.

Metadata

Assignees

No one assigned

    Labels

    needs: implementation specsWe need clarity on HOW we'll implement it from a technical perspectiverestricted: maintainersOnly maintainers can resolve this issuework: backendRelated to Python, Django, and simple SQLwork: frontendRelated to frontend code in the mathesar_ui directory

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions