mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-31 05:44:25 +01:00
fix(3274): Command .schema should work for sqlite_schema
This commit is contained in:
12
cli/app.rs
12
cli/app.rs
@@ -1103,6 +1103,18 @@ impl Limbo {
|
||||
db_display_name: &str,
|
||||
table_name: &str,
|
||||
) -> anyhow::Result<bool> {
|
||||
// Yeah, sqlite also has this hardcoded: https://github.com/sqlite/sqlite/blob/31efe5a0f2f80a263457a1fc6524783c0c45769b/src/shell.c.in#L10765
|
||||
match table_name {
|
||||
"sqlite_master" | "sqlite_schema" | "sqlite_temp_master" | "sqlite_temp_schema" => {
|
||||
let schema = format!(
|
||||
"CREATE TABLE {} (\n type text,\n name text,\n tbl_name text,\n rootpage integer,\n sql text\n);",
|
||||
table_name
|
||||
);
|
||||
let _ = self.writeln(&schema);
|
||||
return Ok(true);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let sql = format!(
|
||||
"SELECT sql, type, name FROM {db_prefix}.sqlite_schema WHERE type IN ('table', 'index', 'view') AND (tbl_name = '{table_name}' OR name = '{table_name}') AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '__turso_internal_%' ORDER BY CASE type WHEN 'table' THEN 1 WHEN 'view' THEN 2 WHEN 'index' THEN 3 END, rowid"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user