Skip to content

Parse temporal values on the front end after pasting #5059

@seancolsen

Description

@seancolsen

Steps to reproduce

  1. Set up a "Date" column for "Date Format" set to "European"

  2. Copy the following string:

    10/11/2000
    
  3. Edit a date cell. Paste the string into the cell in edit mode, pressing Enter to save.

  4. Observe that the value saved displays as you entered it. Good.

  5. With another cell selected (and not in edit mode), use your keyboard shortcut to paste the same string as CSV data.

  6. Expect the cell to display as you entered it again.

  7. Instead, observe that it displays as 11/10/2000. Bad!

What's going on

  1. When you paste the value while in edit mode, the front end parses that value. (See the code in DateTimeFormatter.parse). Since the front end knows the data format is set to European, it uses that format while parsing. It gets the November date and sends it to the backend in ISO format, 2000-11-10.

  2. When you paste the value outside of edit mode, then front end does not parse the value. It sends the string 10/11/2000. Then PostgreSQL parses the value using a locale set somewhere in the PostgreSQL server configuration, which (I think) will default to something like en_US (or however pg represents that). PostgreSQL obtains the date in October. That's bad.

What we need to do

  • Within the paste system, we need to employ the same DateTimeFormatter system that we use in the cell. It needs to be aware of the column data type settings and display options metadata.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedCommunity contributors can implement thisreadyReady for implementationtype: bugwork: frontendRelated to frontend code in the mathesar_ui directory

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions