Skip to content

Commit

Permalink
Revert query command to query db (#6200)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgwood committed Jul 31, 2022
1 parent a83bd4a commit 1086fbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions crates/nu-command/src/database/commands/query.rs
Expand Up @@ -13,17 +13,17 @@ pub struct QueryDb;

impl Command for QueryDb {
fn name(&self) -> &str {
"query"
"query db"
}

fn signature(&self) -> Signature {
Signature::build(self.name())
.required(
"query",
"SQL",
SyntaxShape::String,
"SQL to execute against the database",
)
.input_type(Type::Custom("database".into()))
.input_type(Type::Any)
.output_type(Type::Any)
.category(Category::Custom("database".into()))
}
Expand All @@ -34,8 +34,8 @@ impl Command for QueryDb {

fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Execute a query statement using the database connection",
example: r#"open foo.db | into db | query "SELECT * FROM Bar""#,
description: "Execute SQL against a SQLite database",
example: r#"open foo.db | query db "SELECT * FROM Bar""#,
result: None,
}]
}
Expand Down
8 changes: 3 additions & 5 deletions crates/nu-command/tests/commands/query/db.rs
Expand Up @@ -7,8 +7,7 @@ fn can_query_single_table() {
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.db
| into db
| query "select * from strings"
| query db "select * from strings"
| where x =~ ell
| length
"#
Expand All @@ -24,8 +23,7 @@ fn invalid_sql_fails() {
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample.db
| into db
| query "select *asdfasdf"
| query db "select *asdfasdf"
"#
));

Expand All @@ -38,7 +36,7 @@ fn invalid_input_fails() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
"foo" | into db | query "select * from asdf"
"foo" | query db "select * from asdf"
"#
));

Expand Down

0 comments on commit 1086fbe

Please sign in to comment.