Skip to content

update the sqlite history timestamp and duration with nushell values#17680

Merged
fdncred merged 1 commit intonushell:mainfrom
fdncred:update_sqlite_history_timestamp_duration
Mar 4, 2026
Merged

update the sqlite history timestamp and duration with nushell values#17680
fdncred merged 1 commit intonushell:mainfrom
fdncred:update_sqlite_history_timestamp_duration

Conversation

@fdncred
Copy link
Copy Markdown
Contributor

@fdncred fdncred commented Feb 28, 2026

This PR tries to update the sqlite output of the history file by adding column adapters so we can maintain speed but still get nushell values out of the command.

closes #17666

Release notes summary - What our users need to know

Update the sqlite output of the history file by adding column adapters so we can maintain speed but still get nushell values out of the command.

Before

 history | last
╭─────────────────┬────────────────────────────╮
 start_timestamp  1772317356190              
 command          history | last             
 cwd              /Users/fdncred/src/nushell 
 duration                                    
 exit_status                                 
╰─────────────────┴────────────────────────────╯
 history | last 3
╭─#─┬─start_timestamp─┬─────command──────┬────────────cwd─────────────┬─duration─┬─exit_status─╮
 0    1772317254249  exit              /Users/fdncred/src/nushell                        
 1    1772317356190  history | last    /Users/fdncred/src/nushell         3            0 
 2    1772317382357  history | last 3  /Users/fdncred/src/nushell                        
╰───┴─────────────────┴──────────────────┴────────────────────────────┴──────────┴─────────────╯

After

 history | last
╭─────────────────┬────────────────────────────╮
 start_timestamp  now                        
 command          history | last             
 cwd              /Users/fdncred/src/nushell 
 duration                                    
 exit_status                                 
╰─────────────────┴────────────────────────────╯
 history | last 3
╭─#─┬─start_timestamp─┬─────command──────┬────────────cwd─────────────┬─duration─┬─exit_status─╮
 0  24 seconds ago   exit              /Users/fdncred/src/nushell                        
 1  now              history | last    /Users/fdncred/src/nushell      23ms            0 
 2  now              history | last 3  /Users/fdncred/src/nushell                        
╰───┴─────────────────┴──────────────────┴────────────────────────────┴──────────┴─────────────╯

Tasks after submitting

N/A

/cc @NotTheDr01ds

@fdncred fdncred added status:wait-until-after-nushell-release A:history Related to the history notes:fixes Include the release notes summary in the "Bug fixes" section notes:ready The "Release notes summary" section of this PR is ready to be included in our release notes. labels Feb 28, 2026
@fdncred fdncred merged commit 097d61d into nushell:main Mar 4, 2026
17 checks passed
@fdncred fdncred deleted the update_sqlite_history_timestamp_duration branch March 4, 2026 18:42
@github-actions github-actions bot added this to the v0.112.0 milestone Mar 4, 2026
NotTheDr01ds pushed a commit that referenced this pull request Mar 7, 2026
This PR is a follow-on of these PRs to hopefully finish the last fixing of the sqlite pushdown. The biggest part of this fix is creating mini-sqlite-column-projection code for when sqlite column names are aliased in rust code like `command_line as command`. It's not a fully sql parser but it looks for column aliasing so it knows how to select the data properly. I've tried to comment the code verbosely to help us all remember what it's doing.

- #17415
- #17645
- #17680
- #17668

I also took the opportunity to refactor the push down calls from filter commands so that they're easier to understand by calling a new pipeline function that does the same thing but in a little cleaner way.

There's also a bunch of new tests around `open some_sqlite_file.db`.

Before this PR you would get this with `history | select command`
because `command` is an alias to `command_line`.
```nushell
❯ history | select command
Error: nu::shell::error

  × Failed to execute query
   ╭─[repl_entry #1:1:11]
 1 │ history | select command
   ·           ───┬──
   ·              ╰── no such column: command in SELECT command FROM [history] at offset 7
   ╰────
```
After, it just works (tm)

## Release notes summary - What our users need to know

Refactor sqlite push down and apply to (nearly) all filter commands.

## Tasks after submitting

N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:history Related to the history notes:fixes Include the release notes summary in the "Bug fixes" section notes:ready The "Release notes summary" section of this PR is ready to be included in our release notes. status:wait-until-after-nushell-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression]: start_timestamp column of history command is not a datetime

1 participant