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

@@ -105,18 +105,15 @@ impl Stmt {
match self {
Self::AlterTable(alter_table) => {
let (_, body) = &**alter_table;
match body {
AlterTableBody::AddColumn(cd) => {
for c in cd {
if let ColumnConstraint::PrimaryKey { .. } = c {
return Err(custom_err!("Cannot add a PRIMARY KEY column"));
}
if let ColumnConstraint::Unique(..) = c {
return Err(custom_err!("Cannot add a UNIQUE column"));
}
if let AlterTableBody::AddColumn(cd) = body {
for c in cd {
if let ColumnConstraint::PrimaryKey { .. } = c {
return Err(custom_err!("Cannot add a PRIMARY KEY column"));
}
if let ColumnConstraint::Unique(..) = c {
return Err(custom_err!("Cannot add a UNIQUE column"));
}
}
_ => {}
}
Ok(())
}
@@ -164,10 +161,8 @@ impl Stmt {
let Delete {
order_by, limit, ..
} = &**delete;
if let Some(_) = order_by {
if limit.is_none() {
return Err(custom_err!("ORDER BY without LIMIT on DELETE"));
}
if order_by.is_some() && limit.is_none() {
return Err(custom_err!("ORDER BY without LIMIT on DELETE"));
}
Ok(())
}
@@ -177,7 +172,7 @@ impl Stmt {
return Ok(());
}
let columns = columns.as_ref().unwrap();
match &*body {
match body {
InsertBody::Select(select, ..) => match select.body.select.column_count() {
ColumnCount::Fixed(n) if n != columns.len() => {
Err(custom_err!("{} values for {} columns", n, columns.len()))
@@ -193,10 +188,8 @@ impl Stmt {
let Update {
order_by, limit, ..
} = &**update;
if let Some(_) = order_by {
if limit.is_none() {
return Err(custom_err!("ORDER BY without LIMIT on UPDATE"));
}
if order_by.is_some() && limit.is_none() {
return Err(custom_err!("ORDER BY without LIMIT on UPDATE"));
}
Ok(())