fix warnings and some refactoring

This commit is contained in:
Levy A. 2025-06-03 23:14:07 -03:00
parent 1881cd04b5
commit b88cb99ff0
5 changed files with 12 additions and 23 deletions

View file

@ -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<Self, LimboError> {

View file

@ -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);
}

View file

@ -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};

View file

@ -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: _,

View file

@ -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<String, fmt::Error> {
let mut s = String::new();