Skip to content

Commit 39e4fc9

Browse files
Merge pull request #18 from kemingy/v0.54.x
fix cargo fmt Merge branch 'v0.54.x' into v0.54.x Merge pull request #20 from kemingy/calc_overflow fix lint Merge branch 'v0.54.x' into v0.54.x Merge pull request #19 from kemingy/lint add test for statement convertion fix: overflow in the calculation expr fix the test in another pr fix overflow fix: lint and test fix: add recursive protection to Convert
1 parent 7e0b95b commit 39e4fc9

26 files changed

+202
-182
lines changed

examples/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $ cargo run --example cli - [--dialectname]
6363
};
6464

6565
let contents = if filename == "-" {
66-
println!("Parsing from stdin using {:?}", dialect);
66+
println!("Parsing from stdin using {dialect:?}");
6767
let mut buf = Vec::new();
6868
stdin()
6969
.read_to_end(&mut buf)

sqlparser_bench/benches/sqlparser_bench.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,24 @@ fn basic_queries(c: &mut Criterion) {
4545

4646
let large_statement = {
4747
let expressions = (0..1000)
48-
.map(|n| format!("FN_{}(COL_{})", n, n))
48+
.map(|n| format!("FN_{n}(COL_{n})"))
4949
.collect::<Vec<_>>()
5050
.join(", ");
5151
let tables = (0..1000)
52-
.map(|n| format!("TABLE_{}", n))
52+
.map(|n| format!("TABLE_{n}"))
5353
.collect::<Vec<_>>()
5454
.join(" JOIN ");
5555
let where_condition = (0..1000)
56-
.map(|n| format!("COL_{} = {}", n, n))
56+
.map(|n| format!("COL_{n} = {n}"))
5757
.collect::<Vec<_>>()
5858
.join(" OR ");
5959
let order_condition = (0..1000)
60-
.map(|n| format!("COL_{} DESC", n))
60+
.map(|n| format!("COL_{n} DESC"))
6161
.collect::<Vec<_>>()
6262
.join(", ");
6363

6464
format!(
65-
"SELECT {} FROM {} WHERE {} ORDER BY {}",
66-
expressions, tables, where_condition, order_condition
65+
"SELECT {expressions} FROM {tables} WHERE {where_condition} ORDER BY {order_condition}"
6766
)
6867
};
6968

src/ast/data_type.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ impl fmt::Display for DataType {
609609
}
610610
DataType::Enum(vals, bits) => {
611611
match bits {
612-
Some(bits) => write!(f, "ENUM{}", bits),
612+
Some(bits) => write!(f, "ENUM{bits}"),
613613
None => write!(f, "ENUM"),
614614
}?;
615615
write!(f, "(")?;
@@ -657,16 +657,16 @@ impl fmt::Display for DataType {
657657
}
658658
// ClickHouse
659659
DataType::Nullable(data_type) => {
660-
write!(f, "Nullable({})", data_type)
660+
write!(f, "Nullable({data_type})")
661661
}
662662
DataType::FixedString(character_length) => {
663-
write!(f, "FixedString({})", character_length)
663+
write!(f, "FixedString({character_length})")
664664
}
665665
DataType::LowCardinality(data_type) => {
666-
write!(f, "LowCardinality({})", data_type)
666+
write!(f, "LowCardinality({data_type})")
667667
}
668668
DataType::Map(key_data_type, value_data_type) => {
669-
write!(f, "Map({}, {})", key_data_type, value_data_type)
669+
write!(f, "Map({key_data_type}, {value_data_type})")
670670
}
671671
DataType::Tuple(fields) => {
672672
write!(f, "Tuple({})", display_comma_separated(fields))
@@ -873,7 +873,7 @@ impl fmt::Display for CharacterLength {
873873
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
874874
match self {
875875
CharacterLength::IntegerLength { length, unit } => {
876-
write!(f, "{}", length)?;
876+
write!(f, "{length}")?;
877877
if let Some(unit) = unit {
878878
write!(f, " {unit}")?;
879879
}

src/ast/dcl.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl fmt::Display for AlterRoleOperation {
175175
in_database,
176176
} => {
177177
if let Some(database_name) = in_database {
178-
write!(f, "IN DATABASE {} ", database_name)?;
178+
write!(f, "IN DATABASE {database_name} ")?;
179179
}
180180

181181
match config_value {
@@ -189,7 +189,7 @@ impl fmt::Display for AlterRoleOperation {
189189
in_database,
190190
} => {
191191
if let Some(database_name) = in_database {
192-
write!(f, "IN DATABASE {} ", database_name)?;
192+
write!(f, "IN DATABASE {database_name} ")?;
193193
}
194194

195195
match config_name {
@@ -220,15 +220,15 @@ impl fmt::Display for Use {
220220
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
221221
f.write_str("USE ")?;
222222
match self {
223-
Use::Catalog(name) => write!(f, "CATALOG {}", name),
224-
Use::Schema(name) => write!(f, "SCHEMA {}", name),
225-
Use::Database(name) => write!(f, "DATABASE {}", name),
226-
Use::Warehouse(name) => write!(f, "WAREHOUSE {}", name),
227-
Use::Role(name) => write!(f, "ROLE {}", name),
223+
Use::Catalog(name) => write!(f, "CATALOG {name}"),
224+
Use::Schema(name) => write!(f, "SCHEMA {name}"),
225+
Use::Database(name) => write!(f, "DATABASE {name}"),
226+
Use::Warehouse(name) => write!(f, "WAREHOUSE {name}"),
227+
Use::Role(name) => write!(f, "ROLE {name}"),
228228
Use::SecondaryRoles(secondary_roles) => {
229-
write!(f, "SECONDARY ROLES {}", secondary_roles)
229+
write!(f, "SECONDARY ROLES {secondary_roles}")
230230
}
231-
Use::Object(name) => write!(f, "{}", name),
231+
Use::Object(name) => write!(f, "{name}"),
232232
Use::Default => write!(f, "DEFAULT"),
233233
}
234234
}

src/ast/ddl.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ pub enum Owner {
371371
impl fmt::Display for Owner {
372372
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
373373
match self {
374-
Owner::Ident(ident) => write!(f, "{}", ident),
374+
Owner::Ident(ident) => write!(f, "{ident}"),
375375
Owner::CurrentRole => write!(f, "CURRENT_ROLE"),
376376
Owner::CurrentUser => write!(f, "CURRENT_USER"),
377377
Owner::SessionUser => write!(f, "SESSION_USER"),
@@ -446,7 +446,7 @@ impl fmt::Display for AlterTableOperation {
446446
if *if_not_exists {
447447
write!(f, " IF NOT EXISTS")?;
448448
}
449-
write!(f, " {} ({})", name, query)
449+
write!(f, " {name} ({query})")
450450
}
451451
AlterTableOperation::Algorithm { equals, algorithm } => {
452452
write!(
@@ -461,7 +461,7 @@ impl fmt::Display for AlterTableOperation {
461461
if *if_exists {
462462
write!(f, " IF EXISTS")?;
463463
}
464-
write!(f, " {}", name)
464+
write!(f, " {name}")
465465
}
466466
AlterTableOperation::MaterializeProjection {
467467
if_exists,
@@ -472,9 +472,9 @@ impl fmt::Display for AlterTableOperation {
472472
if *if_exists {
473473
write!(f, " IF EXISTS")?;
474474
}
475-
write!(f, " {}", name)?;
475+
write!(f, " {name}")?;
476476
if let Some(partition) = partition {
477-
write!(f, " IN PARTITION {}", partition)?;
477+
write!(f, " IN PARTITION {partition}")?;
478478
}
479479
Ok(())
480480
}
@@ -487,9 +487,9 @@ impl fmt::Display for AlterTableOperation {
487487
if *if_exists {
488488
write!(f, " IF EXISTS")?;
489489
}
490-
write!(f, " {}", name)?;
490+
write!(f, " {name}")?;
491491
if let Some(partition) = partition {
492-
write!(f, " IN PARTITION {}", partition)?;
492+
write!(f, " IN PARTITION {partition}")?;
493493
}
494494
Ok(())
495495
}
@@ -822,7 +822,7 @@ impl fmt::Display for AlterColumnOperation {
822822
AlterColumnOperation::SetDefault { value } => {
823823
write!(f, "SET DEFAULT {value}")
824824
}
825-
AlterColumnOperation::DropDefault {} => {
825+
AlterColumnOperation::DropDefault => {
826826
write!(f, "DROP DEFAULT")
827827
}
828828
AlterColumnOperation::SetDataType { data_type, using } => {
@@ -1071,7 +1071,7 @@ impl fmt::Display for TableConstraint {
10711071
write!(f, " ON UPDATE {action}")?;
10721072
}
10731073
if let Some(characteristics) = characteristics {
1074-
write!(f, " {}", characteristics)?;
1074+
write!(f, " {characteristics}")?;
10751075
}
10761076
Ok(())
10771077
}
@@ -1309,7 +1309,7 @@ impl fmt::Display for ViewColumnDef {
13091309
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13101310
write!(f, "{}", self.name)?;
13111311
if let Some(data_type) = self.data_type.as_ref() {
1312-
write!(f, " {}", data_type)?;
1312+
write!(f, " {data_type}")?;
13131313
}
13141314
if let Some(options) = self.options.as_ref() {
13151315
write!(f, " {}", display_comma_separated(options.as_slice()))?;
@@ -1690,7 +1690,7 @@ impl fmt::Display for ColumnOption {
16901690
} => {
16911691
write!(f, "{}", if *is_primary { "PRIMARY KEY" } else { "UNIQUE" })?;
16921692
if let Some(characteristics) = characteristics {
1693-
write!(f, " {}", characteristics)?;
1693+
write!(f, " {characteristics}")?;
16941694
}
16951695
Ok(())
16961696
}
@@ -1712,7 +1712,7 @@ impl fmt::Display for ColumnOption {
17121712
write!(f, " ON UPDATE {action}")?;
17131713
}
17141714
if let Some(characteristics) = characteristics {
1715-
write!(f, " {}", characteristics)?;
1715+
write!(f, " {characteristics}")?;
17161716
}
17171717
Ok(())
17181718
}
@@ -1772,7 +1772,7 @@ impl fmt::Display for ColumnOption {
17721772
write!(f, "{parameters}")
17731773
}
17741774
OnConflict(keyword) => {
1775-
write!(f, "ON CONFLICT {:?}", keyword)?;
1775+
write!(f, "ON CONFLICT {keyword:?}")?;
17761776
Ok(())
17771777
}
17781778
Policy(parameters) => {

src/ast/dml.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl Display for CreateTable {
245245
name = self.name,
246246
)?;
247247
if let Some(on_cluster) = &self.on_cluster {
248-
write!(f, " ON CLUSTER {}", on_cluster)?;
248+
write!(f, " ON CLUSTER {on_cluster}")?;
249249
}
250250
if !self.columns.is_empty() || !self.constraints.is_empty() {
251251
write!(f, " ({}", display_comma_separated(&self.columns))?;
@@ -383,10 +383,10 @@ impl Display for CreateTable {
383383
write!(f, " AUTO_INCREMENT {auto_increment_offset}")?;
384384
}
385385
if let Some(primary_key) = &self.primary_key {
386-
write!(f, " PRIMARY KEY {}", primary_key)?;
386+
write!(f, " PRIMARY KEY {primary_key}")?;
387387
}
388388
if let Some(order_by) = &self.order_by {
389-
write!(f, " ORDER BY {}", order_by)?;
389+
write!(f, " ORDER BY {order_by}")?;
390390
}
391391
if let Some(partition_by) = self.partition_by.as_ref() {
392392
write!(f, " PARTITION BY {partition_by}")?;

0 commit comments

Comments
 (0)