mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Initial SQLite functionality (#5182)
* Add SQLite functionality to open * Add in-memory SQLite tests * clippy fixes * Fix up old SQLite-related tests
This commit is contained in:
@ -1,6 +1,4 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
use nu_test_support::pipeline;
|
||||
|
||||
#[test]
|
||||
@ -43,36 +41,16 @@ fn where_not_in_table() {
|
||||
assert_eq!(actual.out, "4");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn explicit_block_condition() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| first 4
|
||||
| where {= $it.z > 4200}
|
||||
| get z
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "4253");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn binary_operator_comparisons() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| get ints
|
||||
| first 4
|
||||
| where z > 4200
|
||||
| get z
|
||||
| get z.0
|
||||
"#
|
||||
));
|
||||
|
||||
@ -82,11 +60,10 @@ fn binary_operator_comparisons() {
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| get ints
|
||||
| first 4
|
||||
| where z >= 4253
|
||||
| get z
|
||||
| get z.0
|
||||
"#
|
||||
));
|
||||
|
||||
@ -96,11 +73,10 @@ fn binary_operator_comparisons() {
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| get ints
|
||||
| first 4
|
||||
| where z < 10
|
||||
| get z
|
||||
| get z.0
|
||||
"#
|
||||
));
|
||||
|
||||
@ -110,11 +86,10 @@ fn binary_operator_comparisons() {
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| get ints
|
||||
| first 4
|
||||
| where z <= 1
|
||||
| get z
|
||||
| get z.0
|
||||
"#
|
||||
));
|
||||
|
||||
@ -124,8 +99,7 @@ fn binary_operator_comparisons() {
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == ints
|
||||
| get table_values
|
||||
| get ints
|
||||
| where z != 1
|
||||
| first 1
|
||||
| get z
|
||||
@ -135,15 +109,13 @@ fn binary_operator_comparisons() {
|
||||
assert_eq!(actual.out, "42");
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[test]
|
||||
fn contains_operator() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == strings
|
||||
| get table_values
|
||||
| get strings
|
||||
| where x =~ ell
|
||||
| length
|
||||
"#
|
||||
@ -155,8 +127,7 @@ fn contains_operator() {
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open sample.db
|
||||
| where table_name == strings
|
||||
| get table_values
|
||||
| get strings
|
||||
| where x !~ ell
|
||||
| length
|
||||
"#
|
||||
|
Reference in New Issue
Block a user