mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 17:54:22 +02:00
Fix to json
for SQLite databases (#8343)
Fixes #8341. The `CustomValue::to_json()` function is an odd duck; it defaults to returning `null`, and no `CustomValue` implementations override it to do anything useful. I forgot to implement `to_json()` for `SQLiteDatabase`, so `open foo.db | to json` was returning `null`. To fix this, I've removed `CustomValue::to_json()` and now `to json` will collect a `CustomValue` into a regular `Value` before doing a JSON conversion.
This commit is contained in:
@ -142,7 +142,10 @@ pub fn value_to_json_value(v: &Value) -> Result<nu_json::Value, ShellError> {
|
||||
let collected = val.collect()?;
|
||||
value_to_json_value(&collected)?
|
||||
}
|
||||
Value::CustomValue { val, .. } => val.to_json(),
|
||||
Value::CustomValue { val, span } => {
|
||||
let collected = val.to_base_value(*span)?;
|
||||
value_to_json_value(&collected)?
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user