chore: fix clippy warnings

This commit is contained in:
Nils Koch
2025-06-13 21:20:26 +01:00
parent 1a0d4f500f
commit 2827b86917
95 changed files with 902 additions and 992 deletions

View File

@@ -71,7 +71,7 @@ impl ToSqlString for Expr {
Expr::Collate(expr, name) => {
ret.push_str(&expr.to_sql_string(context));
ret.push_str(" COLLATE ");
ret.push_str(&name);
ret.push_str(name);
}
Expr::DoublyQualified(name, name1, name2) => {
ret.push_str(&name.0);

View File

@@ -23,7 +23,7 @@ pub trait ToSqlString {
impl<T: ToSqlString> ToSqlString for Box<T> {
fn to_sql_string<C: ToSqlContext>(&self, context: &C) -> String {
T::to_sql_string(&self, context)
T::to_sql_string(self, context)
}
}

View File

@@ -44,7 +44,7 @@ impl ToSqlString for ast::NamedTableConstraint {
self.constraint.to_sql_string(context)
)
} else {
format!("{}", self.constraint.to_sql_string(context))
self.constraint.to_sql_string(context).to_string()
}
}
}

View File

@@ -9,14 +9,22 @@ impl ToSqlString for ast::CreateTrigger {
fn to_sql_string<C: crate::to_sql_string::ToSqlContext>(&self, context: &C) -> String {
format!(
"CREATE{} TRIGGER {}{}{} {} ON {}{}{} BEGIN {} END;",
self.temporary.then_some(" TEMP").unwrap_or(""),
self.if_not_exists.then_some("IF NOT EXISTS ").unwrap_or(""),
if self.temporary { " TEMP" } else { "" },
if self.if_not_exists {
"IF NOT EXISTS "
} else {
""
},
self.trigger_name.to_sql_string(context),
self.time
.map_or("".to_string(), |time| format!(" {}", time)),
self.event,
self.tbl_name.to_sql_string(context),
self.for_each_row.then_some(" FOR EACH ROW").unwrap_or(""),
if self.for_each_row {
" FOR EACH ROW"
} else {
""
},
self.when_clause
.as_ref()
.map_or("".to_string(), |expr| format!(

View File

@@ -4,7 +4,11 @@ impl ToSqlString for ast::CreateVirtualTable {
fn to_sql_string<C: crate::to_sql_string::ToSqlContext>(&self, context: &C) -> String {
format!(
"CREATE VIRTUAL TABLE {}{} USING {}{};",
self.if_not_exists.then_some("IF NOT EXISTS ").unwrap_or(""),
if self.if_not_exists {
"IF NOT EXISTS "
} else {
""
},
self.tbl_name.to_sql_string(context),
self.module_name.0,
self.args

View File

@@ -26,7 +26,7 @@ impl ToSqlString for ast::Stmt {
if let Some(name) = name {
format!("ANALYZE {};", name.to_sql_string(context))
} else {
format!("ANALYZE;")
"ANALYZE;".to_string()
}
}
Self::Attach {
@@ -211,15 +211,15 @@ mod tests {
($test_name:ident, $input:expr) => {
#[test]
fn $test_name() {
let context = crate::to_sql_string::stmt::tests::TestContext;
let context = $crate::to_sql_string::stmt::tests::TestContext;
let input = $input.split_whitespace().collect::<Vec<&str>>().join(" ");
let mut parser = crate::lexer::sql::Parser::new(input.as_bytes());
let mut parser = $crate::lexer::sql::Parser::new(input.as_bytes());
let cmd = fallible_iterator::FallibleIterator::next(&mut parser)
.unwrap()
.unwrap();
assert_eq!(
input,
crate::to_sql_string::ToSqlString::to_sql_string(cmd.stmt(), &context)
$crate::to_sql_string::ToSqlString::to_sql_string(cmd.stmt(), &context)
);
}
};
@@ -227,15 +227,15 @@ mod tests {
#[test]
$(#[$attribute])*
fn $test_name() {
let context = crate::to_sql_string::stmt::tests::TestContext;
let context = $crate::to_sql_string::stmt::tests::TestContext;
let input = $input.split_whitespace().collect::<Vec<&str>>().join(" ");
let mut parser = crate::lexer::sql::Parser::new(input.as_bytes());
let mut parser = $crate::lexer::sql::Parser::new(input.as_bytes());
let cmd = fallible_iterator::FallibleIterator::next(&mut parser)
.unwrap()
.unwrap();
assert_eq!(
input,
crate::to_sql_string::ToSqlString::to_sql_string(cmd.stmt(), &context)
$crate::to_sql_string::ToSqlString::to_sql_string(cmd.stmt(), &context)
);
}
}