mirror of
https://github.com/nushell/nushell.git
synced 2025-05-01 16:44:27 +02:00
# Description This PR fixes #15131 by allowing the `insert` and `upsert` commands to create lists where they may be expected based on the cell path provided. For example, the below would have previously thrown an error, but now creates lists and list elements where necessary <img width="173" alt="Screenshot 2025-02-17 at 2 46 12 AM" src="https://github.com/user-attachments/assets/6d680e7e-6268-42ed-a037-a0795014a7e0" /> <img width="200" alt="Screenshot 2025-02-17 at 2 46 16 AM" src="https://github.com/user-attachments/assets/50d0e8eb-aabb-49fe-b961-5f7489fdc993" /> <img width="284" alt="Screenshot 2025-02-17 at 2 45 43 AM" src="https://github.com/user-attachments/assets/242a2ec6-7e8f-4a51-92ce-9d5ec10f867f" /> # User-Facing Changes This change removes errors that were previously raised by `insert_data_at_cell_path` and `upsert_data_at_cell_path`. If one of these commands encountered an unknown cell path in cases such as these, it would either raise a "Not a list value" as the list index is used on a record: <img width="326" alt="Screenshot 2025-02-17 at 2 46 43 AM" src="https://github.com/user-attachments/assets/39b9b006-388b-49b3-82a0-8cc9b739feaa" /> Or a "Row number too large" when required to create a new list element along the way: <img width="475" alt="Screenshot 2025-02-17 at 2 46 51 AM" src="https://github.com/user-attachments/assets/007d1268-7d26-42aa-9bf5-d54c0abf4058" /> But both now succeed, which seems to be the intention as it is in parity with record behavior. Any consumers depending on this specific behavior will see these errors subside. This change also includes the static method `Value::with_data_at_cell_path` that creates a value with a given nested value at a given cell path, creating records or lists based on the path member type. # Tests + Formatting In addition to unit tests for the altered behavior, both affected user-facing commands (`insert` and `upsert`) gained a new command example to both explain and test this change at the user level. <img width="382" alt="Screenshot 2025-02-17 at 2 29 26 AM" src="https://github.com/user-attachments/assets/e6973640-3ce6-4ea7-9ba5-d256fe5cb38b" /> Note: A single test did fail locally, due to my config directory differing from expected, but works where this variable is unset (`with-env { XDG_CONFIG_HOME: null } {cargo test}`): ``` ---- repl::test_config_path::test_default_config_path stdout ---- thread 'repl::test_config_path::test_default_config_path' panicked at tests/repl/test_config_path.rs:101:5: assertion failed: `(left == right)` Diff < left / right > : <[home_dir]/Library/Application Support/nushell >[home_dir]/.config/nushell ``` |
||
---|---|---|
.. | ||
nu_plugin_custom_values | ||
nu_plugin_example | ||
nu_plugin_formats | ||
nu_plugin_gstat | ||
nu_plugin_inc | ||
nu_plugin_nu_example | ||
nu_plugin_polars | ||
nu_plugin_python | ||
nu_plugin_query | ||
nu_plugin_stress_internals | ||
nu-cli | ||
nu-cmd-base | ||
nu-cmd-extra | ||
nu-cmd-lang | ||
nu-cmd-plugin | ||
nu-color-config | ||
nu-command | ||
nu-derive-value | ||
nu-engine | ||
nu-explore | ||
nu-glob | ||
nu-json | ||
nu-lsp | ||
nu-parser | ||
nu-path | ||
nu-plugin | ||
nu-plugin-core | ||
nu-plugin-engine | ||
nu-plugin-protocol | ||
nu-plugin-test-support | ||
nu-pretty-hex | ||
nu-protocol | ||
nu-std | ||
nu-system | ||
nu-table | ||
nu-term-grid | ||
nu-test-support | ||
nu-utils | ||
nuon | ||
README.md |
Nushell core libraries and plugins
These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.
Foundational libraries are split into two kinds of crates:
- Core crates - those crates that work together to build the Nushell language engine
- Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.
Plugins are likewise also split into two types:
- Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
- Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.