mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-05 00:04:23 +01:00
Fix .schema
- Add tests for .schema - Make command line sql arguments to allow .commands
This commit is contained in:
@@ -40,7 +40,11 @@ fn main() -> anyhow::Result<()> {
|
||||
let db = Database::open_file(io.clone(), path)?;
|
||||
let conn = db.connect();
|
||||
if let Some(sql) = opts.sql {
|
||||
query(io.clone(), &conn, &sql, &opts.output_mode)?;
|
||||
if sql.trim().starts_with('.') {
|
||||
handle_dot_command(io.clone(), &conn, &sql)?;
|
||||
} else {
|
||||
query(io.clone(), &conn, &sql, &opts.output_mode)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let mut rl = DefaultEditor::new()?;
|
||||
|
||||
@@ -42,6 +42,7 @@ pub struct Inner {
|
||||
pub join_clause: Option<Join>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum QueryConstraint {
|
||||
Left(Left),
|
||||
Inner(Inner),
|
||||
@@ -572,7 +573,11 @@ fn get_no_match_target_cursor(
|
||||
let cursors =
|
||||
introspect_expression_for_cursors(program, select, expr, cursor_hint).unwrap_or_default();
|
||||
if cursors.is_empty() {
|
||||
HARDCODED_CURSOR_LEFT_TABLE
|
||||
assert!(
|
||||
select.loops.len() > 0,
|
||||
"select.loops is populated based on select.src_tables. Expect at least 1 table if this function is called"
|
||||
);
|
||||
select.loops.first().unwrap().open_cursor
|
||||
} else {
|
||||
*cursors.iter().max().unwrap()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
|
||||
source $testdir/cmdlineshell.test
|
||||
source $testdir/agg-functions.test
|
||||
source $testdir/coalesce.test
|
||||
source $testdir/join.test
|
||||
|
||||
28
testing/cmdlineshell.test
Normal file
28
testing/cmdlineshell.test
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env tclsh
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_execsql_test schema-1 {
|
||||
.schema users
|
||||
} {{CREATE TABLE users (
|
||||
id INTEGER PRIMARY KEY,
|
||||
first_name TEXT,
|
||||
last_name TEXT,
|
||||
email TEXT,
|
||||
phone_number TEXT,
|
||||
address TEXT,
|
||||
city TEXT,
|
||||
state TEXT,
|
||||
zipcode TEXT,
|
||||
age INTEGER
|
||||
);}}
|
||||
|
||||
do_execsql_test schema-2 {
|
||||
.schema products
|
||||
} {{CREATE TABLE products (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT,
|
||||
price REAL
|
||||
);}}
|
||||
|
||||
Reference in New Issue
Block a user