-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept pipeline input for stor insert
values
#11433
Comments
I'd support that. It should be pretty easy to do. You just have to check for I'm all for making these |
Hi, me and my colleague would like to know if it is still possible to work on this enhancement! |
@JoaoFidalgo1403 Sure. I was just thinking that it could work both ways. If the |
@fdncred Also, would it be ok if we did the same work on |
i think so |
Would something like this be on the right track? I'm new to the code base and a little unfamiliar with the code style. |
@bobby-palmer I think that's probably part of it, although |
- this PR should close #11433 # Description This PR implements pipeline input support for the stor insert and stor update commands, enabling users to directly pass data to these commands without relying solely on flag parameters. Previously, it was only possible to specify the record data using flag parameters, which could be less intuitive and become cumbersome: ```bash stor insert --table-name nudb --data-record {bool1: true, int1: 5, float1: 1.1, str1: fdncred, datetime1: 2023-04-17} stor update --table-name nudb --update-record {str1: nushell datetime1: 2020-04-17} ``` Now it is also possible to pass a record through pipeline input: ```bash {bool1: true, int1: 5, float1: 1.1, str1: fdncred, datetime1: 2023-04-17} | stor insert --table-name nudb {str1: nushell datetime1: 2020-04-17} | stor update --table-name nudb" ``` Changes made on code: - Modified stor insert and stor update to accept a record from the pipeline. - Added logic to handle data from the pipeline record. - Implemented an error case to prevent simultaneous data input from both pipeline and flag. # User-facing changes Returns an error when both ways of inserting data are used. The examples for both commands were updated and in each command, when the -d or -u fags are being used at the same time as input is being passed through the pipeline, it returns an error: ![image](https://github.com/nushell/nushell/assets/120738170/c5b15c1b-716a-4df4-95e8-3bca8f7ae224) Also returns an error when both of them are missing: ![image](https://github.com/nushell/nushell/assets/120738170/47f538ab-79f1-4fcc-9c62-d7a7d60f86a1) # Tests + Formating - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` Co-authored-by: Rodrigo Friães <rodrigo.friaes@tecnico.ulisboa.pt>
@fdncred Can you reopen? As noted in the PR, it only implements passing a record into |
I reopened it but it's pretty confusing to me what the difference is. Maybe there should be a separate issue? |
Related problem
While it's been established that
into sqlite
's ability to append to a database is more a "side-effect" than part of its design, it seems so much simpler thanstor insert
. For example, with a REST call that returns a JSONitems
with a list of records (i.e. a Nu table):With
into sqlite
:This currently works when both creating the database as well as updating, as long as the values match their original positions.
With
stor insert
:(^ from memory - Hope I got those right)
Describe the solution you'd like
Allow
stor insert
to accept pipeline input in the form of either a record:In the second case, I'm guessing the column names would need to be inferred from the first record, which
into sqlite
seems to do when creating (but not updating) the database (to support streaming). Any change in the signature of future records would result in an error.Describe alternatives you've considered
No response
Additional context and details
Would this also work for
stor update
?The text was updated successfully, but these errors were encountered: