Skip to content

Commit 92ac0de

Browse files
committed
chore: Fix old clippy issues
1 parent b04ed04 commit 92ac0de

4 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/ast/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ impl fmt::Display for Statement {
15721572
key_value
15731573
.value
15741574
.iter()
1575-
.map(|value| format!("{} = {}", key_value.key, value.to_string()))
1575+
.map(|value| format!("{} = {}", key_value.key, value))
15761576
.collect::<Vec<String>>()
15771577
.join(", ")
15781578
)
@@ -1605,7 +1605,7 @@ impl fmt::Display for Statement {
16051605
Statement::ShowVariables { filter } => {
16061606
write!(f, "SHOW VARIABLES")?;
16071607
if filter.is_some() {
1608-
write!(f, " {}", filter.as_ref().unwrap().to_string())?;
1608+
write!(f, " {}", filter.as_ref().unwrap())?;
16091609
}
16101610
Ok(())
16111611
}

src/ast/value.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ impl fmt::Display for Value {
9494
write!(
9595
f,
9696
"INTERVAL '{}' SECOND ({}, {})",
97-
value.to_string(),
98-
leading_precision,
99-
fractional_seconds_precision
97+
value, leading_precision, fractional_seconds_precision
10098
)
10199
}
102100
Value::Interval {
@@ -106,7 +104,7 @@ impl fmt::Display for Value {
106104
last_field,
107105
fractional_seconds_precision,
108106
} => {
109-
write!(f, "INTERVAL {}", value.to_string())?;
107+
write!(f, "INTERVAL {}", value)?;
110108

111109
if let Some(leading_field) = leading_field {
112110
write!(f, " {}", leading_field)?;

tests/sqlparser_mysql.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ fn parse_set_transaction() {
222222

223223
#[test]
224224
fn parse_set_variables() {
225+
#[cfg(feature = "bigdecimal")]
226+
let value = Expr::Value(Value::Number(bigdecimal::BigDecimal::from(1_i64), false));
227+
#[cfg(not(feature = "bigdecimal"))]
228+
let value = Expr::Value(Value::Number("1".into(), false));
229+
225230
assert_eq!(
226231
mysql_and_generic().verified_stmt("SET autocommit = 1, sql_mode = 'test'"),
227232
Statement::SetVariable {
@@ -230,7 +235,7 @@ fn parse_set_variables() {
230235
local: false,
231236
hivevar: false,
232237
key: "autocommit".into(),
233-
value: vec![Expr::Value(Value::Number("1".into(), false))],
238+
value: vec![value.clone()],
234239
},
235240
SetVariableKeyValue {
236241
local: false,
@@ -252,7 +257,7 @@ fn parse_set_variables() {
252257
local: true,
253258
hivevar: false,
254259
key: "autocommit".into(),
255-
value: vec![Expr::Value(Value::Number("1".into(), false))],
260+
value: vec![value],
256261
},]
257262
.to_vec()
258263
}

tests/sqlparser_postgres.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,14 +805,20 @@ fn parse_set() {
805805
);
806806

807807
let stmt = pg_and_generic().verified_stmt("SET a = 0");
808+
809+
#[cfg(feature = "bigdecimal")]
810+
let value = Expr::Value(Value::Number(bigdecimal::BigDecimal::from(0_i64), false));
811+
#[cfg(not(feature = "bigdecimal"))]
812+
let value = Expr::Value(Value::Number("0".into(), false));
813+
808814
assert_eq!(
809815
stmt,
810816
Statement::SetVariable {
811817
key_values: [SetVariableKeyValue {
812818
local: false,
813819
hivevar: false,
814820
key: "a".into(),
815-
value: vec![Expr::Value(Value::Number("0".into(), false))],
821+
value: vec![value],
816822
}]
817823
.to_vec()
818824
}

0 commit comments

Comments
 (0)