Database commands (#5307)

* database commands

* db commands

* filesystem opens sqlite file

* clippy error

* corrected error in ci file

* removes matrix flag from ci

* flax matrix for clippy

* add conditional compile for tests

* add conditional compile for tests

* correct order of command

* correct error msg

* correct typo
This commit is contained in:
Fernando Herrera
2022-04-24 10:29:21 +01:00
committed by GitHub
parent c20ba95885
commit e94d13da1b
25 changed files with 845 additions and 223 deletions

View File

@ -39,6 +39,7 @@ mod open;
mod parse;
mod path;
mod prepend;
#[cfg(feature = "database")]
mod query;
mod random;
mod range;

View File

@ -108,8 +108,8 @@ fn parses_more_bson_complexity() {
// │ 4 │ │
// ╰───┴──────╯
#[cfg(feature = "database")]
#[test]
fn parses_sqlite() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
@ -123,6 +123,7 @@ fn parses_sqlite() {
assert_eq!(actual.out, "3");
}
#[cfg(feature = "database")]
#[test]
fn parses_sqlite_get_column_name() {
let actual = nu!(

View File

@ -1,13 +1,12 @@
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"
| db query "select * from strings"
| where x =~ ell
| length
"#
@ -22,7 +21,7 @@ fn invalid_sql_fails() {
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.db
| query db "select *asdfasdf"
| db query "select *asdfasdf"
"#
));
@ -32,11 +31,11 @@ fn invalid_sql_fails() {
#[test]
fn invalid_input_fails() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
cwd: "tests/fixtures/formats", pipeline(
r#"
"foo" | query db "select * from asdf"
"foo" | db query "select * from asdf"
"#
));
assert!(actual.err.contains("pipeline_mismatch"));
assert!(actual.err.contains("can't convert string"));
}

View File

@ -41,6 +41,7 @@ fn where_not_in_table() {
assert_eq!(actual.out, "4");
}
#[cfg(feature = "database")]
#[test]
fn binary_operator_comparisons() {
let actual = nu!(
@ -109,6 +110,7 @@ fn binary_operator_comparisons() {
assert_eq!(actual.out, "42");
}
#[cfg(feature = "database")]
#[test]
fn contains_operator() {
let actual = nu!(