mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-09 03:04:20 +01:00
clippy
This commit is contained in:
@@ -68,7 +68,7 @@ impl ToSqlString for ast::ColumnConstraint {
|
||||
deref_clause,
|
||||
} => format!(
|
||||
"{}{}",
|
||||
clause.to_string(),
|
||||
clause,
|
||||
if let Some(deref) = deref_clause {
|
||||
deref.to_string()
|
||||
} else {
|
||||
@@ -94,10 +94,7 @@ impl ToSqlString for ast::ColumnConstraint {
|
||||
// nullable should always be true here
|
||||
format!(
|
||||
"NOT NULL{}",
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(
|
||||
" {}",
|
||||
conflict.to_string()
|
||||
))
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(" {}", conflict))
|
||||
)
|
||||
}
|
||||
Self::PrimaryKey {
|
||||
@@ -107,21 +104,15 @@ impl ToSqlString for ast::ColumnConstraint {
|
||||
} => {
|
||||
format!(
|
||||
"PRIMARY KEY{}{}{}",
|
||||
order.map_or("".to_string(), |order| format!(" {}", order.to_string())),
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(
|
||||
" {}",
|
||||
conflict.to_string()
|
||||
)),
|
||||
order.map_or("".to_string(), |order| format!(" {}", order)),
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(" {}", conflict)),
|
||||
auto_increment.then_some(" AUTOINCREMENT").unwrap_or("")
|
||||
)
|
||||
}
|
||||
Self::Unique(conflict_clause) => {
|
||||
format!(
|
||||
"UNIQUE{}",
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(
|
||||
" {}",
|
||||
conflict.to_string()
|
||||
))
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(" {}", conflict))
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -166,8 +157,8 @@ impl Display for ast::RefArg {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let value = match self {
|
||||
Self::Match(name) => format!("MATCH {}", name.0),
|
||||
Self::OnDelete(act) => format!("ON DELETE {}", act.to_string()),
|
||||
Self::OnUpdate(act) => format!("ON UPDATE {}", act.to_string()),
|
||||
Self::OnDelete(act) => format!("ON DELETE {}", act),
|
||||
Self::OnUpdate(act) => format!("ON UPDATE {}", act),
|
||||
Self::OnInsert(..) => unimplemented!(
|
||||
"On Insert does not exist in SQLite: https://www.sqlite.org/lang_altertable.html"
|
||||
),
|
||||
|
||||
@@ -28,7 +28,7 @@ impl ToSqlString for ast::CreateTableBody {
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
)),
|
||||
options.to_string()
|
||||
options
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ impl ToSqlString for ast::TableConstraint {
|
||||
.map(|col| col.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", "),
|
||||
clause.to_string(),
|
||||
clause,
|
||||
if let Some(deref) = deref_clause {
|
||||
deref.to_string()
|
||||
} else {
|
||||
@@ -82,10 +82,7 @@ impl ToSqlString for ast::TableConstraint {
|
||||
.map(|col| col.to_sql_string(context))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", "),
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(
|
||||
" {}",
|
||||
conflict.to_string()
|
||||
)),
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(" {}", conflict)),
|
||||
auto_increment.then_some(" AUTOINCREMENT").unwrap_or("")
|
||||
),
|
||||
Self::Unique {
|
||||
@@ -98,10 +95,7 @@ impl ToSqlString for ast::TableConstraint {
|
||||
.map(|col| col.to_sql_string(context))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", "),
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(
|
||||
" {}",
|
||||
conflict.to_string()
|
||||
))
|
||||
conflict_clause.map_or("".to_string(), |conflict| format!(" {}", conflict))
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ impl ToSqlString for ast::CreateTrigger {
|
||||
self.if_not_exists.then_some("IF NOT EXISTS ").unwrap_or(""),
|
||||
self.trigger_name.to_sql_string(context),
|
||||
self.time
|
||||
.map_or("".to_string(), |time| format!(" {}", time.to_string())),
|
||||
self.event.to_string(),
|
||||
.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(""),
|
||||
self.when_clause
|
||||
@@ -97,10 +97,8 @@ impl ToSqlString for ast::TriggerCmdInsert {
|
||||
// TODO: no DEFAULT VALUES
|
||||
format!(
|
||||
"INSERT {}INTO {} {}{}{}{}",
|
||||
self.or_conflict.map_or("".to_string(), |conflict| format!(
|
||||
"OR {} ",
|
||||
conflict.to_string()
|
||||
)),
|
||||
self.or_conflict
|
||||
.map_or("".to_string(), |conflict| format!("OR {} ", conflict)),
|
||||
self.tbl_name.0,
|
||||
self.col_names
|
||||
.as_ref()
|
||||
@@ -216,10 +214,8 @@ impl ToSqlString for ast::TriggerCmdUpdate {
|
||||
fn to_sql_string<C: crate::to_sql_string::ToSqlContext>(&self, context: &C) -> String {
|
||||
format!(
|
||||
"UPDATE {}{} SET {}{}{}",
|
||||
self.or_conflict.map_or("".to_string(), |conflict| format!(
|
||||
"OR {}",
|
||||
conflict.to_string()
|
||||
)),
|
||||
self.or_conflict
|
||||
.map_or("".to_string(), |conflict| format!("OR {}", conflict)),
|
||||
self.tbl_name.0, // TODO: should be a qualified table name,
|
||||
self.sets
|
||||
.iter()
|
||||
|
||||
@@ -11,10 +11,7 @@ impl ToSqlString for ast::Delete {
|
||||
self.tbl_name.to_sql_string(context),
|
||||
self.indexed
|
||||
.as_ref()
|
||||
.map_or("".to_string(), |indexed| format!(
|
||||
" {}",
|
||||
indexed.to_string()
|
||||
)),
|
||||
.map_or("".to_string(), |indexed| format!(" {}", indexed)),
|
||||
self.where_clause
|
||||
.as_ref()
|
||||
.map_or("".to_string(), |expr| format!(
|
||||
|
||||
@@ -8,10 +8,8 @@ impl ToSqlString for ast::Insert {
|
||||
"{} ",
|
||||
with.to_sql_string(context)
|
||||
)),
|
||||
self.or_conflict.map_or("".to_string(), |conflict| format!(
|
||||
"OR {} ",
|
||||
conflict.to_string()
|
||||
)),
|
||||
self.or_conflict
|
||||
.map_or("".to_string(), |conflict| format!("OR {} ", conflict)),
|
||||
self.tbl_name.to_sql_string(context),
|
||||
self.columns
|
||||
.as_ref()
|
||||
|
||||
@@ -359,7 +359,7 @@ impl Display for ast::JoinOperator {
|
||||
Self::TypedJoin(join) => {
|
||||
let join_keyword = "JOIN";
|
||||
if let Some(join) = join {
|
||||
format!("{} {}", join.to_string(), join_keyword)
|
||||
format!("{} {}", join, join_keyword)
|
||||
} else {
|
||||
join_keyword.to_string()
|
||||
}
|
||||
|
||||
@@ -8,17 +8,12 @@ impl ToSqlString for ast::Update {
|
||||
"{} ",
|
||||
with.to_sql_string(context)
|
||||
)),
|
||||
self.or_conflict.map_or("".to_string(), |conflict| format!(
|
||||
"OR {} ",
|
||||
conflict.to_string()
|
||||
)),
|
||||
self.or_conflict
|
||||
.map_or("".to_string(), |conflict| format!("OR {} ", conflict)),
|
||||
self.tbl_name.to_sql_string(context),
|
||||
self.indexed
|
||||
.as_ref()
|
||||
.map_or("".to_string(), |indexed| format!(
|
||||
" {}",
|
||||
indexed.to_string()
|
||||
)),
|
||||
.map_or("".to_string(), |indexed| format!(" {}", indexed)),
|
||||
self.sets
|
||||
.iter()
|
||||
.map(|set| set.to_sql_string(context))
|
||||
|
||||
Reference in New Issue
Block a user