Skip to content

Fix nested update closure for table columns - #18205

Merged
fdncred merged 1 commit into
nushell:mainfrom
fdncred:help_update_work_nested
Jun 1, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
fdncred:help_update_work_nested

Conversation

@fdncred

@fdncred fdncred commented May 14, 2026

Copy link
Copy Markdown
Contributor

Description

This fixes a bug where update with a nested column path and closure (for example rss_item.pubDate) could evaluate the closure against a projected list and write the same result back to every row.

  • Switched nested closure updates to a recursive per-cell traversal so closures run once per targeted leaf value.
  • Preserved existing behavior for index-first paths (for example update 0.a with a closure).

User-facing changes (Release notes)

This fixes a bug where update with a nested column path and closure (for example rss_item.pubDate) could evaluate the closure against a projected list and write the same result back to every row.

Before

{
  rss_item: [
    [  pubDate];
    [1773429600],
    [1774325700],
    [1775448000]
  ]
} | update rss_item.pubDate { into datetime -f "%s" } | table -e
╭──────────┬──────────────────────────────╮
│          │ ╭─#─┬───────pubDate────────╮ │
│ rss_item │ │ 0 │ ╭───┬──────────────╮ │ │
│          │ │   │ │ 0 │ 2 months ago │ │ │
│          │ │   │ │ 1 │ 2 months ago │ │ │
│          │ │   │ │ 2 │ a month ago  │ │ │
│          │ │   │ ╰───┴──────────────╯ │ │
│          │ │ 1 │ ╭───┬──────────────╮ │ │
│          │ │   │ │ 0 │ 2 months ago │ │ │
│          │ │   │ │ 1 │ 2 months ago │ │ │
│          │ │   │ │ 2 │ a month ago  │ │ │
│          │ │   │ ╰───┴──────────────╯ │ │
│          │ │ 2 │ ╭───┬──────────────╮ │ │
│          │ │   │ │ 0 │ 2 months ago │ │ │
│          │ │   │ │ 1 │ 2 months ago │ │ │
│          │ │   │ │ 2 │ a month ago  │ │ │
│          │ │   │ ╰───┴──────────────╯ │ │
│          │ ╰─#─┴───────pubDate────────╯ │
╰──────────┴──────────────────────────────╯

After

{
  rss_item: [
    [  pubDate];
    [1773429600],
    [1774325700],
    [1775448000]
  ]
} | update rss_item.pubDate { into datetime -f "%s" } | table -e
╭──────────┬──────────────────────╮
│          │ ╭─#─┬───pubDate────╮ │
│ rss_item │ │ 0 │ 2 months ago │ │
│          │ │ 1 │ 2 months ago │ │
│          │ │ 2 │ a month ago  │ │
│          │ ╰───┴──────────────╯ │
╰──────────┴──────────────────────╯

Before

{ w: { x: [ { y: "1" } { y: "2" } ] } } | update w.x.y { into float } | to yaml
w:
  x:
    - 'y':
        - 1.0
        - 2.0
    - 'y':
        - 1.0
        - 2.0

After

{ w: { x: [ { y: "1" } { y: "2" } ] } } | update w.x.y { into float } | to yaml
w:
  x:
    - 'y': 1.0
    - 'y': 2.0

Before

[{w: {x: [{y: "1"} {y: "2"}]}}] | update w.x.y { into float } | to yaml
- w:
    x:
      - 'y':
          - 1.0
          - 2.0
      - 'y':
          - 1.0
          - 2.0

After

[{w: {x: [{y: "1"} {y: "2"}]}}] | update w.x.y { into float } | to yaml
- w:
    x:
      - 'y': 1.0
      - 'y': 2.0

Before

[ [[a]; [1] [2]] ] | update a {into float} | to yaml
-
  - a:
      - 1.0
      - 2.0
  - a:
      - 1.0
      - 2.0

After

[ [[a]; [1] [2]] ] | update a {into float} | to yaml
-
  - a: 1.0
  - a: 2.0

Additional notes

closes #15726
related #15789

@fdncred
fdncred merged commit f439db3 into nushell:main Jun 1, 2026
25 of 34 checks passed
@fdncred
fdncred deleted the help_update_work_nested branch June 1, 2026 14:01
@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Jun 1, 2026
@github-actions github-actions Bot added this to the v0.114.0 milestone Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the "update" command provides wrong $in in subtables

1 participant