Skip to content

Commit 1a3694f

Browse files
committed
Cargo fmt
1 parent 31ae6f3 commit 1a3694f

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
@@ -2840,7 +2840,7 @@ impl<'a> Parser<'a> {
28402840
} else {
28412841
return Err(ParserError::ParserError(
28422842
"Scale field can only be of number type".to_string(),
2843-
))
2843+
));
28442844
}
28452845
} else {
28462846
CeilFloorKind::DateTimeField(DateTimeField::NoDateTime)
@@ -20041,9 +20041,9 @@ impl<'a> Parser<'a> {
2004120041
self.next_token();
2004220042
Ok(KeyValueOption {
2004320043
option_name: key.value.clone(),
20044-
option_value: KeyValueOptionKind::Single(Value::Placeholder(
20045-
word.value.clone(),
20046-
).with_span(peeked_token.span)),
20044+
option_value: KeyValueOptionKind::Single(
20045+
Value::Placeholder(word.value.clone()).with_span(peeked_token.span),
20046+
),
2004720047
})
2004820048
}
2004920049
Token::LParen => {
@@ -20056,12 +20056,10 @@ impl<'a> Parser<'a> {
2005620056
parser.expect_token(&Token::RParen)?;
2005720057
values
2005820058
})? {
20059-
Some(values) => {
20060-
Ok(KeyValueOption {
20061-
option_name: key.value.clone(),
20062-
option_value: KeyValueOptionKind::Multi(values),
20063-
})
20064-
}
20059+
Some(values) => Ok(KeyValueOption {
20060+
option_name: key.value.clone(),
20061+
option_value: KeyValueOptionKind::Multi(values),
20062+
}),
2006520063
None => Ok(KeyValueOption {
2006620064
option_name: key.value.clone(),
2006720065
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
);
@@ -17666,19 +17670,21 @@ fn parse_create_user() {
1766617670
options: vec![
1766717671
KeyValueOption {
1766817672
option_name: "PASSWORD".to_string(),
17669-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
17670-
"secret".to_string()
17671-
).with_empty_span()),
17673+
option_value: KeyValueOptionKind::Single(
17674+
Value::SingleQuotedString("secret".to_string()).with_empty_span()
17675+
),
1767217676
},
1767317677
KeyValueOption {
1767417678
option_name: "MUST_CHANGE_PASSWORD".to_string(),
17675-
option_value: KeyValueOptionKind::Single(Value::Boolean(false).with_empty_span()),
17679+
option_value: KeyValueOptionKind::Single(
17680+
Value::Boolean(false).with_empty_span()
17681+
),
1767617682
},
1767717683
KeyValueOption {
1767817684
option_name: "TYPE".to_string(),
17679-
option_value: KeyValueOptionKind::Single(Value::Placeholder(
17680-
"SERVICE".to_string()
17681-
).with_empty_span()),
17685+
option_value: KeyValueOptionKind::Single(
17686+
Value::Placeholder("SERVICE".to_string()).with_empty_span()
17687+
),
1768217688
},
1768317689
],
1768417690
},
@@ -17691,15 +17697,15 @@ fn parse_create_user() {
1769117697
options: vec![
1769217698
KeyValueOption {
1769317699
option_name: "t1".to_string(),
17694-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
17695-
"v1".to_string()
17696-
).with_empty_span()),
17700+
option_value: KeyValueOptionKind::Single(
17701+
Value::SingleQuotedString("v1".to_string()).with_empty_span()
17702+
),
1769717703
},
1769817704
KeyValueOption {
1769917705
option_name: "t2".to_string(),
17700-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
17701-
"v2".to_string()
17702-
).with_empty_span()),
17706+
option_value: KeyValueOptionKind::Single(
17707+
Value::SingleQuotedString("v2".to_string()).with_empty_span()
17708+
),
1770317709
},
1770417710
]
1770517711
}
@@ -18325,9 +18331,9 @@ fn test_parse_alter_user() {
1832518331
alter.set_tag.options,
1832618332
vec![KeyValueOption {
1832718333
option_name: "k1".to_string(),
18328-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
18329-
"v1".to_string()
18330-
).with_empty_span()),
18334+
option_value: KeyValueOptionKind::Single(
18335+
Value::SingleQuotedString("v1".to_string()).with_empty_span()
18336+
),
1833118337
},]
1833218338
);
1833318339
}
@@ -18361,17 +18367,21 @@ fn test_parse_alter_user() {
1836118367
options: vec![
1836218368
KeyValueOption {
1836318369
option_name: "PASSWORD".to_string(),
18364-
option_value: KeyValueOptionKind::Single(Value::SingleQuotedString(
18365-
"secret".to_string()
18366-
).with_empty_span()),
18370+
option_value: KeyValueOptionKind::Single(
18371+
Value::SingleQuotedString("secret".to_string()).with_empty_span()
18372+
),
1836718373
},
1836818374
KeyValueOption {
1836918375
option_name: "MUST_CHANGE_PASSWORD".to_string(),
18370-
option_value: KeyValueOptionKind::Single(Value::Boolean(true).with_empty_span()),
18376+
option_value: KeyValueOptionKind::Single(
18377+
Value::Boolean(true).with_empty_span()
18378+
),
1837118379
},
1837218380
KeyValueOption {
1837318381
option_name: "MINS_TO_UNLOCK".to_string(),
18374-
option_value: KeyValueOptionKind::Single(number("10").with_empty_span()),
18382+
option_value: KeyValueOptionKind::Single(
18383+
number("10").with_empty_span()
18384+
),
1837518385
},
1837618386
]
1837718387
}
@@ -18398,7 +18408,8 @@ fn test_parse_alter_user() {
1839818408
option_name: "DEFAULT_SECONDARY_ROLES".to_string(),
1839918409
option_value: KeyValueOptionKind::Multi(vec![Value::SingleQuotedString(
1840018410
"ALL".to_string()
18401-
).with_empty_span()])
18411+
)
18412+
.with_empty_span()])
1840218413
}]
1840318414
);
1840418415
}
@@ -18422,16 +18433,17 @@ fn test_parse_alter_user() {
1842218433
options: vec![
1842318434
KeyValueOption {
1842418435
option_name: "TYPE".to_string(),
18425-
option_value: KeyValueOptionKind::Single(Value::Placeholder(
18426-
"AWS".to_string()
18427-
).with_empty_span()),
18436+
option_value: KeyValueOptionKind::Single(
18437+
Value::Placeholder("AWS".to_string()).with_empty_span()
18438+
),
1842818439
},
1842918440
KeyValueOption {
1843018441
option_name: "ARN".to_string(),
1843118442
option_value: KeyValueOptionKind::Single(
1843218443
Value::SingleQuotedString(
1843318444
"arn:aws:iam::123456789:r1/".to_string()
18434-
).with_empty_span()
18445+
)
18446+
.with_empty_span()
1843518447
),
1843618448
},
1843718449
]

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)