SQLite overhaul: custom value, query db command (#5247)

Clean up query errors
This commit is contained in:
Reilly Wood
2022-04-19 21:58:21 -07:00
committed by GitHub
parent c0ce1e9057
commit b501db673a
13 changed files with 519 additions and 207 deletions

View File

@ -39,6 +39,7 @@ mod open;
mod parse;
mod path;
mod prepend;
mod query;
mod random;
mod range;
mod reduce;

View File

@ -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#"

View 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);
}

View File

@ -0,0 +1 @@
mod db;