This commit is contained in:
alpaylan
2025-07-13 11:10:52 -04:00
96 changed files with 1142 additions and 1094 deletions

View File

@@ -299,7 +299,7 @@ impl Display for ast::Operator {
Self::RightShift => ">>",
Self::Subtract => "-",
};
write!(f, "{}", value)
write!(f, "{value}")
}
}

View File

@@ -94,7 +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))
conflict_clause.map_or("".to_string(), |conflict| format!(" {conflict}"))
)
}
Self::PrimaryKey {
@@ -104,15 +104,15 @@ impl ToSqlString for ast::ColumnConstraint {
} => {
format!(
"PRIMARY KEY{}{}{}",
order.map_or("".to_string(), |order| format!(" {}", order)),
conflict_clause.map_or("".to_string(), |conflict| format!(" {}", conflict)),
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))
conflict_clause.map_or("".to_string(), |conflict| format!(" {conflict}"))
)
}
}
@@ -149,7 +149,7 @@ impl Display for ast::ForeignKeyClause {
"".to_string()
}
);
write!(f, "{}", value)
write!(f, "{value}")
}
}
@@ -157,13 +157,13 @@ 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),
Self::OnUpdate(act) => format!("ON UPDATE {}", act),
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"
),
};
write!(f, "{}", value)
write!(f, "{value}")
}
}
@@ -176,7 +176,7 @@ impl Display for ast::RefAct {
Self::SetDefault => "SET DEFAULT",
Self::SetNull => "SET NULL",
};
write!(f, "{}", value)
write!(f, "{value}")
}
}
@@ -198,7 +198,7 @@ impl Display for ast::DeferSubclause {
""
}
);
write!(f, "{}", value)
write!(f, "{value}")
}
}
#[cfg(test)]

View File

@@ -82,7 +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)),
conflict_clause.map_or("".to_string(), |conflict| format!(" {conflict}")),
auto_increment.then_some(" AUTOINCREMENT").unwrap_or("")
),
Self::Unique {
@@ -95,7 +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))
conflict_clause.map_or("".to_string(), |conflict| format!(" {conflict}"))
),
}
}

View File

@@ -16,8 +16,7 @@ impl ToSqlString for ast::CreateTrigger {
""
},
self.trigger_name.to_sql_string(context),
self.time
.map_or("".to_string(), |time| format!(" {}", time)),
self.time.map_or("".to_string(), |time| format!(" {time}")),
self.event,
self.tbl_name.to_sql_string(context),
if self.for_each_row {
@@ -106,7 +105,7 @@ impl ToSqlString for ast::TriggerCmdInsert {
format!(
"INSERT {}INTO {} {}{}{}{}",
self.or_conflict
.map_or("".to_string(), |conflict| format!("OR {} ", conflict)),
.map_or("".to_string(), |conflict| format!("OR {conflict} ")),
self.tbl_name.0,
self.col_names
.as_ref()
@@ -223,7 +222,7 @@ impl ToSqlString for ast::TriggerCmdUpdate {
format!(
"UPDATE {}{} SET {}{}{}",
self.or_conflict
.map_or("".to_string(), |conflict| format!("OR {}", conflict)),
.map_or("".to_string(), |conflict| format!("OR {conflict}")),
self.tbl_name.0, // TODO: should be a qualified table name,
self.sets
.iter()

View File

@@ -11,7 +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)),
.map_or("".to_string(), |indexed| format!(" {indexed}")),
self.where_clause
.as_ref()
.map_or("".to_string(), |expr| format!(

View File

@@ -9,7 +9,7 @@ impl ToSqlString for ast::Insert {
with.to_sql_string(context)
)),
self.or_conflict
.map_or("".to_string(), |conflict| format!("OR {} ", conflict)),
.map_or("".to_string(), |conflict| format!("OR {conflict} ")),
self.tbl_name.to_sql_string(context),
self.columns
.as_ref()

View File

@@ -49,7 +49,7 @@ impl ToSqlString for ast::Stmt {
ast::TransactionType::Exclusive => " EXCLUSIVE",
ast::TransactionType::Immediate => " IMMEDIATE",
});
format!("BEGIN{};", t_type)
format!("BEGIN{t_type};")
}
// END or COMMIT are equivalent here, so just defaulting to COMMIT
// TODO: again there are no names in the docs

View File

@@ -21,7 +21,7 @@ impl ToSqlString for ast::Select {
.map(|col| col.to_sql_string(context))
.collect::<Vec<_>>()
.join(", ");
ret.push(format!("ORDER BY {}", joined_cols));
ret.push(format!("ORDER BY {joined_cols}"));
}
if let Some(limit) = &self.limit {
ret.push(limit.to_sql_string(context));
@@ -65,11 +65,11 @@ impl ToSqlString for ast::OneSelect {
.map(|e| e.to_sql_string(context))
.collect::<Vec<_>>()
.join(", ");
format!("({})", joined_value)
format!("({joined_value})")
})
.collect::<Vec<_>>()
.join(", ");
format!("VALUES {}", joined_values)
format!("VALUES {joined_values}")
}
}
}
@@ -239,7 +239,7 @@ impl ToSqlString for ast::CommonTableExpr {
.collect::<Vec<_>>()
.join(", ");
ret.push(format!("({})", joined_cols));
ret.push(format!("({joined_cols})"));
}
ret.push(format!(
"AS {}({})",
@@ -296,7 +296,7 @@ impl Display for ast::Materialized {
Self::No => "NOT MATERIALIZED",
Self::Yes => "MATERIALIZED",
};
write!(f, "{}", value)
write!(f, "{value}")
}
}
@@ -360,7 +360,7 @@ impl Display for ast::JoinOperator {
Self::TypedJoin(join) => {
let join_keyword = "JOIN";
if let Some(join) = join {
format!("{} {}", join, join_keyword)
format!("{join} {join_keyword}")
} else {
join_keyword.to_string()
}
@@ -400,7 +400,7 @@ impl Display for ast::JoinType {
}
modifiers.join(" ")
};
write!(f, "{}", value)
write!(f, "{value}")
}
}
@@ -416,7 +416,7 @@ impl ToSqlString for ast::JoinConstraint {
.map(|col| col.0.clone())
.collect::<Vec<_>>()
.join(",");
format!("USING ({})", joined_names)
format!("USING ({joined_names})")
}
}
}
@@ -457,7 +457,7 @@ impl ToSqlString for ast::Window {
.map(|e| e.to_sql_string(context))
.collect::<Vec<_>>()
.join(",");
ret.push(format!("PARTITION BY {}", joined_exprs));
ret.push(format!("PARTITION BY {joined_exprs}"));
}
if let Some(order_by) = &self.order_by {
let joined_cols = order_by
@@ -465,7 +465,7 @@ impl ToSqlString for ast::Window {
.map(|col| col.to_sql_string(context))
.collect::<Vec<_>>()
.join(", ");
ret.push(format!("ORDER BY {}", joined_cols));
ret.push(format!("ORDER BY {joined_cols}"));
}
if let Some(frame_claue) = &self.frame_clause {
ret.push(frame_claue.to_sql_string(context));
@@ -523,7 +523,7 @@ impl Display for ast::FrameExclude {
Self::NoOthers => "NO OTHERS",
Self::Ties => "TIES",
};
format!("EXCLUDE {}", clause)
format!("EXCLUDE {clause}")
})
}
}

View File

@@ -9,11 +9,11 @@ impl ToSqlString for ast::Update {
with.to_sql_string(context)
)),
self.or_conflict
.map_or("".to_string(), |conflict| format!("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)),
.map_or("".to_string(), |indexed| format!(" {indexed}")),
self.sets
.iter()
.map(|set| set.to_sql_string(context))