mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
SQLite overhaul: custom value, query db
command (#5247)
Clean up query errors
This commit is contained in:
@ -39,6 +39,7 @@ mod open;
|
||||
mod parse;
|
||||
mod path;
|
||||
mod prepend;
|
||||
mod query;
|
||||
mod random;
|
||||
mod range;
|
||||
mod reduce;
|
||||
|
@ -109,7 +109,22 @@ fn parses_more_bson_complexity() {
|
||||
// ╰───┴──────╯
|
||||
|
||||
#[test]
|
||||
|
||||
fn parses_sqlite() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| columns
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_sqlite_get_column_name() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
|
47
crates/nu-command/tests/commands/query/db.rs
Normal file
47
crates/nu-command/tests/commands/query/db.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
|
||||
fn can_query_single_table() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| query db "select * from strings"
|
||||
| where x =~ ell
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_sql_fails() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| query db "select *asdfasdf"
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("syntax error"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_input_fails() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
"foo" | query db "select * from asdf"
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("pipeline_mismatch"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scratch() {
|
||||
assert!(true);
|
||||
}
|
1
crates/nu-command/tests/commands/query/mod.rs
Normal file
1
crates/nu-command/tests/commands/query/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
mod db;
|
Reference in New Issue
Block a user