nushell/crates/nu-command
Skyler Hawthorne cf923fc44c
into sqlite: Fix insertion of null values (#12328)
# Description

In #10232, the allowed input types were changed to be stricter, only
allowing records with types that can easily map onto sqlite equivalents.
Unfortunately, null was left out of the accepted input types, which
makes inserting rows with null values impossible.

This change fixes that by accepting null values as input.

One caveat of this is that when the command is creating a new table, it
uses the first row to infer an appropriate sqlite schema. If the first
row contains a null value, then it is impossible to tell which type this
column is supposed to have.

Throwing a hard error seems undesirable from a UX perspective, but
guessing can lead to a potentially useless database if we guess wrong.

So as a compromise, for null columns, we will assume the sqlite type is
TEXT and print a warning so the user knows. For the time being, if users
can't avoid a first row with null values, but also wants the right
schema, they are advised to create their table before running `into
sqlite`.

A future PR can add the ability to explicitly specify a schema.

Fixes #12225

# Tests + Formatting

* Tests added to cover expected behavior around insertion of null values
2024-03-29 06:41:16 -05:00
..
src into sqlite: Fix insertion of null values (#12328) 2024-03-29 06:41:16 -05:00
tests into sqlite: Fix insertion of null values (#12328) 2024-03-29 06:41:16 -05:00
Cargo.toml Change default algorithm in detect columns (#12277) 2024-03-26 13:57:55 +08:00
LICENSE Fix rest of license year ranges (#8727) 2023-04-04 09:03:29 +12:00