Skip to content

Commit b6a8af1

Browse files
committed
chore: fix fmt
1 parent cee5ac8 commit b6a8af1

File tree

6 files changed

+20
-59
lines changed

6 files changed

+20
-59
lines changed

examples/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $ cargo run --feature json_example --example cli FILENAME.sql [--dialectname]
7575
#[cfg(feature = "json_example")]
7676
{
7777
let serialized = serde_json::to_string_pretty(&statements).unwrap();
78-
println!("Serialized as JSON:\n{}", serialized);
78+
println!("Serialized as JSON:\n{serialized}");
7979
}
8080
} else {
8181
println!("Parse results:\n{statements:#?}");

src/ast/ddl.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,7 @@ impl fmt::Display for AlterTableOperation {
183183
AlterTableOperation::RenameColumn {
184184
old_column_name,
185185
new_column_name,
186-
} => write!(
187-
f,
188-
"RENAME COLUMN {old_column_name} TO {new_column_name}"
189-
),
186+
} => write!(f, "RENAME COLUMN {old_column_name} TO {new_column_name}"),
190187
AlterTableOperation::RenameTable { table_name } => {
191188
write!(f, "RENAME TO {table_name}")
192189
}

src/ast/mod.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,10 +2454,7 @@ impl fmt::Display for Statement {
24542454
Ok(())
24552455
}
24562456
Statement::ShowCreate { obj_type, obj_name } => {
2457-
write!(
2458-
f,
2459-
"SHOW CREATE {obj_type} {obj_name}",
2460-
)?;
2457+
write!(f, "SHOW CREATE {obj_type} {obj_name}",)?;
24612458
Ok(())
24622459
}
24632460
Statement::ShowColumns {
@@ -2690,10 +2687,7 @@ impl fmt::Display for Statement {
26902687
if_exists,
26912688
} => {
26922689
if *if_exists {
2693-
write!(
2694-
f,
2695-
"UNCACHE TABLE IF EXISTS {table_name}"
2696-
)
2690+
write!(f, "UNCACHE TABLE IF EXISTS {table_name}")
26972691
} else {
26982692
write!(f, "UNCACHE TABLE {table_name}")
26992693
}
@@ -4178,10 +4172,7 @@ mod tests {
41784172
Expr::Identifier(Ident::new("d")),
41794173
],
41804174
]);
4181-
assert_eq!(
4182-
"GROUPING SETS ((a, b), (c, d))",
4183-
format!("{grouping_sets}")
4184-
);
4175+
assert_eq!("GROUPING SETS ((a, b), (c, d))", format!("{grouping_sets}"));
41854176
}
41864177

41874178
#[test]

src/ast/query.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ impl fmt::Display for SetExpr {
108108
} => {
109109
write!(f, "{left} {op}")?;
110110
match set_quantifier {
111-
SetQuantifier::All | SetQuantifier::Distinct => {
112-
write!(f, " {set_quantifier}")?
113-
}
111+
SetQuantifier::All | SetQuantifier::Distinct => write!(f, " {set_quantifier}")?,
114112
SetQuantifier::None => write!(f, "{set_quantifier}")?,
115113
}
116114
write!(f, " {right}")?;

src/ast/visitor.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,32 +600,32 @@ mod tests {
600600
type Break = ();
601601

602602
fn pre_visit_relation(&mut self, relation: &ObjectName) -> ControlFlow<Self::Break> {
603-
self.visited.push(format!("PRE: RELATION: {}", relation));
603+
self.visited.push(format!("PRE: RELATION: {relation}"));
604604
ControlFlow::Continue(())
605605
}
606606

607607
fn post_visit_relation(&mut self, relation: &ObjectName) -> ControlFlow<Self::Break> {
608-
self.visited.push(format!("POST: RELATION: {}", relation));
608+
self.visited.push(format!("POST: RELATION: {relation}"));
609609
ControlFlow::Continue(())
610610
}
611611

612612
fn pre_visit_expr(&mut self, expr: &Expr) -> ControlFlow<Self::Break> {
613-
self.visited.push(format!("PRE: EXPR: {}", expr));
613+
self.visited.push(format!("PRE: EXPR: {expr}"));
614614
ControlFlow::Continue(())
615615
}
616616

617617
fn post_visit_expr(&mut self, expr: &Expr) -> ControlFlow<Self::Break> {
618-
self.visited.push(format!("POST: EXPR: {}", expr));
618+
self.visited.push(format!("POST: EXPR: {expr}"));
619619
ControlFlow::Continue(())
620620
}
621621

622622
fn pre_visit_statement(&mut self, statement: &Statement) -> ControlFlow<Self::Break> {
623-
self.visited.push(format!("PRE: STATEMENT: {}", statement));
623+
self.visited.push(format!("PRE: STATEMENT: {statement}"));
624624
ControlFlow::Continue(())
625625
}
626626

627627
fn post_visit_statement(&mut self, statement: &Statement) -> ControlFlow<Self::Break> {
628-
self.visited.push(format!("POST: STATEMENT: {}", statement));
628+
self.visited.push(format!("POST: STATEMENT: {statement}"));
629629
ControlFlow::Continue(())
630630
}
631631
}

tests/sqlparser_common.rs

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,9 +2827,7 @@ fn parse_alter_table_drop_column() {
28272827
#[test]
28282828
fn parse_alter_table_alter_column() {
28292829
let alter_stmt = "ALTER TABLE tab";
2830-
match verified_stmt(&format!(
2831-
"{alter_stmt} ALTER COLUMN is_active SET NOT NULL"
2832-
)) {
2830+
match verified_stmt(&format!("{alter_stmt} ALTER COLUMN is_active SET NOT NULL")) {
28332831
Statement::AlterTable {
28342832
name,
28352833
operation: AlterTableOperation::AlterColumn { column_name, op },
@@ -2865,9 +2863,7 @@ fn parse_alter_table_alter_column() {
28652863
_ => unreachable!(),
28662864
}
28672865

2868-
match verified_stmt(&format!(
2869-
"{alter_stmt} ALTER COLUMN is_active DROP DEFAULT"
2870-
)) {
2866+
match verified_stmt(&format!("{alter_stmt} ALTER COLUMN is_active DROP DEFAULT")) {
28712867
Statement::AlterTable {
28722868
name,
28732869
operation: AlterTableOperation::AlterColumn { column_name, op },
@@ -2912,9 +2908,7 @@ fn parse_alter_table_alter_column_type() {
29122908

29132909
let res = Parser::parse_sql(
29142910
&GenericDialect {},
2915-
&format!(
2916-
"{alter_stmt} ALTER COLUMN is_active SET DATA TYPE TEXT USING 'text'"
2917-
),
2911+
&format!("{alter_stmt} ALTER COLUMN is_active SET DATA TYPE TEXT USING 'text'"),
29182912
);
29192913
assert_eq!(
29202914
ParserError::ParserError("Expected end of statement, found: USING".to_string()),
@@ -4266,9 +4260,7 @@ fn parse_cte_renamed_columns() {
42664260
#[test]
42674261
fn parse_recursive_cte() {
42684262
let cte_query = "SELECT 1 UNION ALL SELECT val + 1 FROM nums WHERE val < 10".to_owned();
4269-
let sql = &format!(
4270-
"WITH RECURSIVE nums (val) AS ({cte_query}) SELECT * FROM nums"
4271-
);
4263+
let sql = &format!("WITH RECURSIVE nums (val) AS ({cte_query}) SELECT * FROM nums");
42724264

42734265
let cte_query = verified_query(&cte_query);
42744266
let query = verified_query(sql);
@@ -6280,9 +6272,7 @@ fn parse_cache_table() {
62806272
let query = all_dialects().verified_query(sql);
62816273

62826274
assert_eq!(
6283-
verified_stmt(
6284-
format!("CACHE TABLE '{cache_table_name}'").as_str()
6285-
),
6275+
verified_stmt(format!("CACHE TABLE '{cache_table_name}'").as_str()),
62866276
Statement::Cache {
62876277
table_flag: None,
62886278
table_name: ObjectName(vec![Ident::with_quote('\'', cache_table_name)]),
@@ -6293,12 +6283,7 @@ fn parse_cache_table() {
62936283
);
62946284

62956285
assert_eq!(
6296-
verified_stmt(
6297-
format!(
6298-
"CACHE {table_flag} TABLE '{cache_table_name}'"
6299-
)
6300-
.as_str()
6301-
),
6286+
verified_stmt(format!("CACHE {table_flag} TABLE '{cache_table_name}'").as_str()),
63026287
Statement::Cache {
63036288
table_flag: Some(ObjectName(vec![Ident::new(table_flag)])),
63046289
table_name: ObjectName(vec![Ident::with_quote('\'', cache_table_name)]),
@@ -6384,12 +6369,7 @@ fn parse_cache_table() {
63846369
);
63856370

63866371
assert_eq!(
6387-
verified_stmt(
6388-
format!(
6389-
"CACHE {table_flag} TABLE '{cache_table_name}' {sql}"
6390-
)
6391-
.as_str()
6392-
),
6372+
verified_stmt(format!("CACHE {table_flag} TABLE '{cache_table_name}' {sql}").as_str()),
63936373
Statement::Cache {
63946374
table_flag: Some(ObjectName(vec![Ident::new(table_flag)])),
63956375
table_name: ObjectName(vec![Ident::with_quote('\'', cache_table_name)]),
@@ -6400,12 +6380,7 @@ fn parse_cache_table() {
64006380
);
64016381

64026382
assert_eq!(
6403-
verified_stmt(
6404-
format!(
6405-
"CACHE {table_flag} TABLE '{cache_table_name}' AS {sql}"
6406-
)
6407-
.as_str()
6408-
),
6383+
verified_stmt(format!("CACHE {table_flag} TABLE '{cache_table_name}' AS {sql}").as_str()),
64096384
Statement::Cache {
64106385
table_flag: Some(ObjectName(vec![Ident::new(table_flag)])),
64116386
table_name: ObjectName(vec![Ident::with_quote('\'', cache_table_name)]),

0 commit comments

Comments
 (0)