diff --git a/core/function.rs b/core/function.rs index 971c7dde2..d3207ad0b 100644 --- a/core/function.rs +++ b/core/function.rs @@ -612,7 +612,7 @@ impl Func { #[cfg(feature = "json")] Self::Json(json_func) => json_func.is_deterministic(), Self::External(external_func) => external_func.is_deterministic(), - Self::AlterTable(alter_func) => true, + Self::AlterTable(_) => true, } } pub fn resolve_function(name: &str, arg_count: usize) -> Result { diff --git a/core/schema.rs b/core/schema.rs index d9a1f0ed0..2f2ad4fdf 100644 --- a/core/schema.rs +++ b/core/schema.rs @@ -1499,13 +1499,7 @@ mod tests { #[test] pub fn test_sqlite_schema() { - let expected = r#"CREATE TABLE sqlite_schema ( - type TEXT, - name TEXT, - tbl_name TEXT, - rootpage INTEGER, - sql TEXT) -"#; + let expected = r#"CREATE TABLE sqlite_schema (type TEXT, name TEXT, tbl_name TEXT, rootpage INTEGER, sql TEXT) "#; let actual = sqlite_schema_table().to_sql(); assert_eq!(expected, actual); } diff --git a/core/translate/expr.rs b/core/translate/expr.rs index c1494e702..dbcdb47ff 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -6,7 +6,7 @@ use super::optimizer::Optimizable; use super::plan::TableReferences; #[cfg(feature = "json")] use crate::function::JsonFunc; -use crate::function::{AlterTableFunc, Func, FuncCtx, MathFuncArity, ScalarFunc, VectorFunc}; +use crate::function::{Func, FuncCtx, MathFuncArity, ScalarFunc, VectorFunc}; use crate::functions::datetime; use crate::schema::{Affinity, Table, Type}; use crate::util::{exprs_are_equivalent, normalize_ident, parse_numeric_literal}; diff --git a/core/translate/schema.rs b/core/translate/schema.rs index ab96f24b6..fd8ee0ef3 100644 --- a/core/translate/schema.rs +++ b/core/translate/schema.rs @@ -1,5 +1,4 @@ use std::collections::HashSet; -use std::fmt::Display; use std::ops::Range; use std::rc::Rc; @@ -441,20 +440,16 @@ enum PrimaryKeyDefinitionType<'a> { }, } -struct TableFormatter<'a> { - body: &'a ast::CreateTableBody, -} - -impl Display for TableFormatter<'_> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.body.to_fmt(f) - } -} - fn create_table_body_to_str(tbl_name: &ast::QualifiedName, body: &ast::CreateTableBody) -> String { let mut sql = String::new(); - let formatter = TableFormatter { body }; - sql.push_str(format!("CREATE TABLE {} {}", tbl_name.name.0, formatter).as_str()); + sql.push_str( + format!( + "CREATE TABLE {} {}", + tbl_name.name.0, + body.format().unwrap() + ) + .as_str(), + ); match body { ast::CreateTableBody::ColumnsAndConstraints { columns: _, diff --git a/vendored/sqlite3-parser/src/parser/ast/fmt.rs b/vendored/sqlite3-parser/src/parser/ast/fmt.rs index 72f1b2a8b..6598e71d7 100644 --- a/vendored/sqlite3-parser/src/parser/ast/fmt.rs +++ b/vendored/sqlite3-parser/src/parser/ast/fmt.rs @@ -102,7 +102,7 @@ pub trait ToTokens { let mut s = FmtTokenStream { f, spaced: true }; self.to_tokens(&mut s) } - // Format AST node to string + /// Format AST node to string fn format(&self) -> Result { let mut s = String::new();