Skip to content

Cell path display output doesn't escape/quote properly #13362

Closed

Description

@sholderbach

Describe the bug

The current Display implementation for CellPath directly outputs both the string key/column members and int row. This makes it impossible to distinguish columns from rows should they contain only numbers or contain a dot.

How to reproduce

> $.0."0"
0.0
> $."foo.bar".baz
foo.bar.baz

Expected behavior

Either...

> $.0."0"
0."0"
> $."foo.bar".baz
"foo.bar".baz

... or

> $.0."0"
$.0."0"
> $."foo.bar".baz
$."foo.bar".baz

Configuration

key value
version 0.95.1
major 0
minor 95
patch 1
branch main
commit_hash f65bc97
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel 1.77.2-x86_64-unknown-linux-gnu
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-07-12 10:59:10 +02:00
build_rust_channel debug
allocator mimalloc
features default, sqlite, system-clipboard, trash
installed_plugins

Activity

  1. added
    status:needs-triage
    category:bug
    and removed
    status:needs-triage
    on Jul 12, 2024
  2. changed the title [-]Cell path output doesn't escape/quote properly[/-] [+]Cell path display output doesn't escape/quote properly[/+] on Jul 12, 2024
  3. sholderbach commented on Jul 12, 2024

    @sholderbach
    MemberAuthor

    Additional challenges:

    • should this include a unique prefix as in $. to be equivalent to its literal?
    • Which quoting/escaping routine to use, on top of detection of . or all digits, this also has to take into account the used quotes or what escape sequences are active in those.
    • Funky interaction with select currently flattening deep nested acesses using Display (see Fix select cell path renaming behavior #13361)
  4. fdncred commented on Jul 12, 2024

    @fdncred
    Contributor

    Seems like the original intent of the cell-path literal was to be able to construct cell-paths and then use them for select and maybe get. So, however we change it, we need to ensure that still works.

    let cp = $."foo.bar".baz
    $table | select $cp

    We also need to keep in mind that we have into cell-path as well so theoretically there may need to be changes there too.

  5. sholderbach commented on Jul 12, 2024

    @sholderbach
    MemberAuthor

    Currently into cell-path only accepts either an index or a structured form as a list or table so it doesn't have the full parsing logic to deal with (so unquoting/unescaping) and can immediately generate unique/correct cell paths.

    I think when showing such a cell path it should be pretty much equivalent to the corresponding literal.

  6. IanManske commented on Jul 13, 2024

    @IanManske
    Member

    Another thing to note is that the Display implementation for CellPath is used when serializing cell paths to nuon. Because of this escaping issue, $value | to nuon | from nuon may not return the same value.

    should this include a unique prefix as in $. to be equivalent to its literal?

    I'm leaning towards yes, but I thinking leaving the prefix out is also fine.

  7. added
    A:cell-path-semantics
    on Aug 16, 2024
  8. added this to the v0.100.0 milestone on Nov 2, 2024
  9. added a commit that references this issue on Nov 2, 2024
    1c3ff17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:cell-path-semanticscategory:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions