Skip to content

Commit 6c3e018

Browse files
committed
Cargo fmt
1 parent 1632293 commit 6c3e018

File tree

9 files changed

+128
-95
lines changed

9 files changed

+128
-95
lines changed

src/ast/helpers/key_value_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use serde::{Deserialize, Serialize};
2929
#[cfg(feature = "visitor")]
3030
use sqlparser_derive::{Visit, VisitMut};
3131

32-
use crate::ast::{ValueWithSpan, display_comma_separated, display_separated};
32+
use crate::ast::{display_comma_separated, display_separated, ValueWithSpan};
3333

3434
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3535
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

src/ast/spans.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ use super::{
4646
RenameSelectItem, ReplaceSelectElement, ReplaceSelectItem, Select, SelectInto, SelectItem,
4747
SetExpr, SqlOption, Statement, Subscript, SymbolDefinition, TableAlias, TableAliasColumnDef,
4848
TableConstraint, TableFactor, TableObject, TableOptionsClustered, TableWithJoins, Update,
49-
UpdateTableFromKind, Use, Values, ViewColumnDef, WhileStatement,
50-
WildcardAdditionalOptions, With, WithFill,
49+
UpdateTableFromKind, Use, Values, ViewColumnDef, WhileStatement, WildcardAdditionalOptions,
50+
With, WithFill,
5151
};
5252

5353
/// Given an iterator of spans, return the [Span::union] of all spans.

src/ast/value.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
#[cfg(not(feature = "std"))]
1919
use alloc::string::String;
2020

21-
use core::{fmt, ops::{Deref, DerefMut}};
21+
use core::{
22+
fmt,
23+
ops::{Deref, DerefMut},
24+
};
2225

2326
#[cfg(feature = "bigdecimal")]
2427
use bigdecimal::BigDecimal;
@@ -67,7 +70,11 @@ use sqlparser_derive::{Visit, VisitMut};
6770
/// A `Value` paired with its source `Span` location.
6871
#[derive(Debug, Clone, Eq)]
6972
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
70-
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut), visit(with = "visit_value"))]
73+
#[cfg_attr(
74+
feature = "visitor",
75+
derive(Visit, VisitMut),
76+
visit(with = "visit_value")
77+
)]
7178
pub struct ValueWithSpan {
7279
/// The wrapped `Value`.
7380
pub value: Value,

src/dialect/snowflake.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use crate::ast::{
3939
use crate::dialect::{Dialect, Precedence};
4040
use crate::keywords::Keyword;
4141
use crate::parser::{IsOptional, Parser, ParserError};
42-
use crate::tokenizer::{Span, Token};
4342
use crate::tokenizer::TokenWithSpan;
43+
use crate::tokenizer::{Span, Token};
4444
#[cfg(not(feature = "std"))]
4545
use alloc::boxed::Box;
4646
#[cfg(not(feature = "std"))]
@@ -1653,7 +1653,8 @@ fn parse_session_options(
16531653
Value::Placeholder(empty()).with_span(Span {
16541654
start: peeked_token.span.end,
16551655
end: peeked_token.span.end,
1656-
})),
1656+
}),
1657+
),
16571658
});
16581659
}
16591660
}

src/parser/alter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ use alloc::{string::ToString, vec};
1818
use super::{Parser, ParserError};
1919
use crate::{
2020
ast::{
21+
helpers::key_value_options::{KeyValueOptions, KeyValueOptionsDelimiter},
2122
AlterConnectorOwner, AlterPolicy, AlterPolicyOperation, AlterRoleOperation, AlterUser,
2223
AlterUserAddMfaMethodOtp, AlterUserAddRoleDelegation, AlterUserModifyMfaMethod,
2324
AlterUserPassword, AlterUserRemoveRoleDelegation, AlterUserSetPolicy, Expr, MfaMethodKind,
2425
Password, ResetConfig, RoleOption, SetConfigValue, Statement, UserPolicyKind,
25-
helpers::key_value_options::{KeyValueOptions, KeyValueOptionsDelimiter},
2626
},
2727
dialect::{MsSqlDialect, PostgreSqlDialect},
2828
keywords::Keyword,

src/parser/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,7 +2839,7 @@ impl<'a> Parser<'a> {
28392839
} else {
28402840
return Err(ParserError::ParserError(
28412841
"Scale field can only be of number type".to_string(),
2842-
))
2842+
));
28432843
}
28442844
} else {
28452845
CeilFloorKind::DateTimeField(DateTimeField::NoDateTime)
@@ -20040,9 +20040,9 @@ impl<'a> Parser<'a> {
2004020040
self.next_token();
2004120041
Ok(KeyValueOption {
2004220042
option_name: key.value.clone(),
20043-
option_value: KeyValueOptionKind::Single(Value::Placeholder(
20044-
word.value.clone(),
20045-
).with_span(peeked_token.span)),
20043+
option_value: KeyValueOptionKind::Single(
20044+
Value::Placeholder(word.value.clone()).with_span(peeked_token.span),
20045+
),
2004620046
})
2004720047
}
2004820048
Token::LParen => {
@@ -20055,12 +20055,10 @@ impl<'a> Parser<'a> {
2005520055
parser.expect_token(&Token::RParen)?;
2005620056
values
2005720057
})? {
20058-
Some(values) => {
20059-
Ok(KeyValueOption {
20060-
option_name: key.value.clone(),
20061-
option_value: KeyValueOptionKind::Multi(values),
20062-
})
20063-
}
20058+
Some(values) => Ok(KeyValueOption {
20059+
option_name: key.value.clone(),
20060+
option_value: KeyValueOptionKind::Multi(values),
20061+
}),
2006420062
None => Ok(KeyValueOption {
2006520063
option_name: key.value.clone(),
2006620064
option_value: KeyValueOptionKind::KeyValueOptions(Box::new(

tests/sqlparser_common.rs

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3324,7 +3324,9 @@ fn parse_ceil_scale() {
33243324
assert_eq!(
33253325
&Expr::Ceil {
33263326
expr: Box::new(Expr::Identifier(Ident::new("d"))),
3327-
field: CeilFloorKind::Scale(Value::Number(bigdecimal::BigDecimal::from(2), false).with_empty_span()),
3327+
field: CeilFloorKind::Scale(
3328+
Value::Number(bigdecimal::BigDecimal::from(2), false).with_empty_span()
3329+
),
33283330
},
33293331
expr_from_projection(only(&select.projection)),
33303332
);
@@ -3348,7 +3350,9 @@ fn parse_floor_scale() {
33483350
assert_eq!(
33493351
&Expr::Floor {
33503352
expr: Box::new(Expr::Identifier(Ident::new("d"))),
3351-
field: CeilFloorKind::Scale(Value::Number(bigdecimal::BigDecimal::from(2), false).with_empty_span()),
3353+
field: CeilFloorKind::Scale(
3354+
Value::Number(bigdecimal::BigDecimal::from(2), false).with_empty_span()
3355+
),
33523356
},
33533357
expr_from_projection(only(&select.projection)),
33543358
);
@@ -17638,19 +17642,21 @@ fn parse_create_user() {
1763817642
options: vec![
1763917643
KeyValueOption {
1764017644
option_name: "PASSWORD".to_string(),
17641-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
17642-
"secret".to_string()
17643-
).with_empty_span()),
17645+
option_value: KeyValueOptionKind::Single(
17646+
Value::SingleQuotedString("secret".to_string()).with_empty_span()
17647+
),
1764417648
},
1764517649
KeyValueOption {
1764617650
option_name: "MUST_CHANGE_PASSWORD".to_string(),
17647-
option_value: KeyValueOptionKind::Single(Value::Boolean(false).with_empty_span()),
17651+
option_value: KeyValueOptionKind::Single(
17652+
Value::Boolean(false).with_empty_span()
17653+
),
1764817654
},
1764917655
KeyValueOption {
1765017656
option_name: "TYPE".to_string(),
17651-
option_value: KeyValueOptionKind::Single(Value::Placeholder(
17652-
"SERVICE".to_string()
17653-
).with_empty_span()),
17657+
option_value: KeyValueOptionKind::Single(
17658+
Value::Placeholder("SERVICE".to_string()).with_empty_span()
17659+
),
1765417660
},
1765517661
],
1765617662
},
@@ -17663,15 +17669,15 @@ fn parse_create_user() {
1766317669
options: vec![
1766417670
KeyValueOption {
1766517671
option_name: "t1".to_string(),
17666-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
17667-
"v1".to_string()
17668-
).with_empty_span()),
17672+
option_value: KeyValueOptionKind::Single(
17673+
Value::SingleQuotedString("v1".to_string()).with_empty_span()
17674+
),
1766917675
},
1767017676
KeyValueOption {
1767117677
option_name: "t2".to_string(),
17672-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
17673-
"v2".to_string()
17674-
).with_empty_span()),
17678+
option_value: KeyValueOptionKind::Single(
17679+
Value::SingleQuotedString("v2".to_string()).with_empty_span()
17680+
),
1767517681
},
1767617682
]
1767717683
}
@@ -18297,9 +18303,9 @@ fn test_parse_alter_user() {
1829718303
alter.set_tag.options,
1829818304
vec![KeyValueOption {
1829918305
option_name: "k1".to_string(),
18300-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
18301-
"v1".to_string()
18302-
).with_empty_span()),
18306+
option_value: KeyValueOptionKind::Single(
18307+
Value::SingleQuotedString("v1".to_string()).with_empty_span()
18308+
),
1830318309
},]
1830418310
);
1830518311
}
@@ -18333,17 +18339,21 @@ fn test_parse_alter_user() {
1833318339
options: vec![
1833418340
KeyValueOption {
1833518341
option_name: "PASSWORD".to_string(),
18336-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
18337-
"secret".to_string()
18338-
).with_empty_span()),
18342+
option_value: KeyValueOptionKind::Single(
18343+
Value::SingleQuotedString("secret".to_string()).with_empty_span()
18344+
),
1833918345
},
1834018346
KeyValueOption {
1834118347
option_name: "MUST_CHANGE_PASSWORD".to_string(),
18342-
option_value: KeyValueOptionKind::Single(Value::Boolean(true).with_empty_span()),
18348+
option_value: KeyValueOptionKind::Single(
18349+
Value::Boolean(true).with_empty_span()
18350+
),
1834318351
},
1834418352
KeyValueOption {
1834518353
option_name: "MINS_TO_UNLOCK".to_string(),
18346-
option_value: KeyValueOptionKind::Single(number("10").with_empty_span()),
18354+
option_value: KeyValueOptionKind::Single(
18355+
number("10").with_empty_span()
18356+
),
1834718357
},
1834818358
]
1834918359
}
@@ -18370,7 +18380,8 @@ fn test_parse_alter_user() {
1837018380
option_name: "DEFAULT_SECONDARY_ROLES".to_string(),
1837118381
option_value: KeyValueOptionKind::Multi(vec![Value::SingleQuotedString(
1837218382
"ALL".to_string()
18373-
).with_empty_span()])
18383+
)
18384+
.with_empty_span()])
1837418385
}]
1837518386
);
1837618387
}
@@ -18394,16 +18405,17 @@ fn test_parse_alter_user() {
1839418405
options: vec![
1839518406
KeyValueOption {
1839618407
option_name: "TYPE".to_string(),
18397-
option_value: KeyValueOptionKind::Single(Value::Placeholder(
18398-
"AWS".to_string()
18399-
).with_empty_span()),
18408+
option_value: KeyValueOptionKind::Single(
18409+
Value::Placeholder("AWS".to_string()).with_empty_span()
18410+
),
1840018411
},
1840118412
KeyValueOption {
1840218413
option_name: "ARN".to_string(),
1840318414
option_value: KeyValueOptionKind::Single(
1840418415
Value::SingleQuotedString(
1840518416
"arn:aws:iam::123456789:r1/".to_string()
18406-
).with_empty_span()
18417+
)
18418+
.with_empty_span()
1840718419
),
1840818420
},
1840918421
]

tests/sqlparser_mysql.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4233,7 +4233,10 @@ fn parse_match_against_with_alias() {
42334233
Ident::new("ReferenceID")
42344234
])]
42354235
);
4236-
assert_eq!(match_value, Value::SingleQuotedString("AAA".to_owned()).with_empty_span());
4236+
assert_eq!(
4237+
match_value,
4238+
Value::SingleQuotedString("AAA".to_owned()).with_empty_span()
4239+
);
42374240
assert_eq!(opt_search_modifier, Some(SearchModifier::InBooleanMode));
42384241
}
42394242
_ => unreachable!(),

0 commit comments

Comments
 (0)