Skip to content

Commit 515fbfb

Browse files
committed
Cargo fmt
1 parent f3359c6 commit 515fbfb

4 files changed

Lines changed: 75 additions & 57 deletions

File tree

src/ast/query.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,15 +1230,20 @@ pub enum ConnectByKind {
12301230
impl fmt::Display for ConnectByKind {
12311231
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12321232
match self {
1233-
ConnectByKind::ConnectBy { relationships, nocycle } => {
1234-
write!(f, "CONNECT BY {nocycle}{relationships}",
1233+
ConnectByKind::ConnectBy {
1234+
relationships,
1235+
nocycle,
1236+
} => {
1237+
write!(
1238+
f,
1239+
"CONNECT BY {nocycle}{relationships}",
12351240
nocycle = if *nocycle { "NOCYCLE " } else { "" },
12361241
relationships = display_comma_separated(relationships)
12371242
)
1238-
},
1243+
}
12391244
ConnectByKind::StartWith(condition) => {
12401245
write!(f, "START WITH {condition}")
1241-
},
1246+
}
12421247
}
12431248
}
12441249
}

src/ast/spans.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,9 +2284,10 @@ impl Spanned for Select {
22842284
impl Spanned for ConnectByKind {
22852285
fn span(&self) -> Span {
22862286
match self {
2287-
ConnectByKind::ConnectBy { relationships, nocycle: _ } => {
2288-
union_spans(relationships.iter().map(|item| item.span()))
2289-
}
2287+
ConnectByKind::ConnectBy {
2288+
relationships,
2289+
nocycle: _,
2290+
} => union_spans(relationships.iter().map(|item| item.span())),
22902291
ConnectByKind::StartWith(expr) => expr.span(),
22912292
}
22922293
}

src/parser/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14280,7 +14280,10 @@ impl<'a> Parser<'a> {
1428014280
let relationships = self.with_state(ParserState::ConnectBy, |parser| {
1428114281
parser.parse_comma_separated(Parser::parse_expr)
1428214282
})?;
14283-
clauses.push(ConnectByKind::ConnectBy { relationships, nocycle });
14283+
clauses.push(ConnectByKind::ConnectBy {
14284+
relationships,
14285+
nocycle,
14286+
});
1428414287
} else {
1428514288
break;
1428614289
}

tests/sqlparser_common.rs

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12653,56 +12653,63 @@ fn parse_connect_by() {
1265312653
"ORDER BY employee_id"
1265412654
);
1265512655

12656-
assert_eq!(dialects.verified_only_select(connect_by_1), Select {
12657-
select_token: AttachedToken::empty(),
12658-
optimizer_hint: None,
12659-
distinct: None,
12660-
select_modifiers: None,
12661-
top: None,
12662-
top_before_distinct: false,
12663-
projection: vec![
12664-
SelectItem::UnnamedExpr(Expr::Identifier(Ident::new("employee_id"))),
12665-
SelectItem::UnnamedExpr(Expr::Identifier(Ident::new("manager_id"))),
12666-
SelectItem::UnnamedExpr(Expr::Identifier(Ident::new("title"))),
12667-
],
12668-
exclude: None,
12669-
from: vec![TableWithJoins {
12670-
relation: table_from_name(ObjectName::from(vec![Ident::new("employees")])),
12671-
joins: vec![],
12672-
}],
12673-
into: None,
12674-
lateral_views: vec![],
12675-
prewhere: None,
12676-
selection: None,
12677-
group_by: GroupByExpr::Expressions(vec![], vec![]),
12678-
cluster_by: vec![],
12679-
distribute_by: vec![],
12680-
sort_by: vec![],
12681-
having: None,
12682-
named_window: vec![],
12683-
qualify: None,
12684-
window_before_qualify: false,
12685-
value_table_mode: None,
12686-
connect_by: vec![
12687-
ConnectByKind::StartWith(Expr::BinaryOp {
12688-
left: Box::new(Expr::Identifier(Ident::new("title"))),
12689-
op: BinaryOperator::Eq,
12690-
right: Box::new(Expr::Value(
12691-
Value::SingleQuotedString("president".to_owned()).with_empty_span(),
12692-
)),
12693-
}.into()),
12694-
ConnectByKind::ConnectBy {
12695-
relationships: vec![Expr::BinaryOp {
12696-
left: Box::new(Expr::Identifier(Ident::new("manager_id"))),
12697-
op: BinaryOperator::Eq,
12698-
right: Box::new(Expr::Prior(Box::new(Expr::Identifier(Ident::new(
12699-
"employee_id",
12700-
))))),
12701-
}],
12702-
nocycle: false,
12656+
assert_eq!(
12657+
dialects.verified_only_select(connect_by_1),
12658+
Select {
12659+
select_token: AttachedToken::empty(),
12660+
optimizer_hint: None,
12661+
distinct: None,
12662+
select_modifiers: None,
12663+
top: None,
12664+
top_before_distinct: false,
12665+
projection: vec![
12666+
SelectItem::UnnamedExpr(Expr::Identifier(Ident::new("employee_id"))),
12667+
SelectItem::UnnamedExpr(Expr::Identifier(Ident::new("manager_id"))),
12668+
SelectItem::UnnamedExpr(Expr::Identifier(Ident::new("title"))),
12669+
],
12670+
exclude: None,
12671+
from: vec![TableWithJoins {
12672+
relation: table_from_name(ObjectName::from(vec![Ident::new("employees")])),
12673+
joins: vec![],
1270312674
}],
12704-
flavor: SelectFlavor::Standard,
12705-
});
12675+
into: None,
12676+
lateral_views: vec![],
12677+
prewhere: None,
12678+
selection: None,
12679+
group_by: GroupByExpr::Expressions(vec![], vec![]),
12680+
cluster_by: vec![],
12681+
distribute_by: vec![],
12682+
sort_by: vec![],
12683+
having: None,
12684+
named_window: vec![],
12685+
qualify: None,
12686+
window_before_qualify: false,
12687+
value_table_mode: None,
12688+
connect_by: vec![
12689+
ConnectByKind::StartWith(
12690+
Expr::BinaryOp {
12691+
left: Box::new(Expr::Identifier(Ident::new("title"))),
12692+
op: BinaryOperator::Eq,
12693+
right: Box::new(Expr::Value(
12694+
Value::SingleQuotedString("president".to_owned()).with_empty_span(),
12695+
)),
12696+
}
12697+
.into()
12698+
),
12699+
ConnectByKind::ConnectBy {
12700+
relationships: vec![Expr::BinaryOp {
12701+
left: Box::new(Expr::Identifier(Ident::new("manager_id"))),
12702+
op: BinaryOperator::Eq,
12703+
right: Box::new(Expr::Prior(Box::new(Expr::Identifier(Ident::new(
12704+
"employee_id",
12705+
))))),
12706+
}],
12707+
nocycle: false,
12708+
}
12709+
],
12710+
flavor: SelectFlavor::Standard,
12711+
}
12712+
);
1270612713

1270712714
// CONNECT BY can come before START WITH
1270812715
let connect_by_2 = concat!(
@@ -12717,6 +12724,7 @@ fn parse_connect_by() {
1271712724
select_token: AttachedToken::empty(),
1271812725
optimizer_hint: None,
1271912726
distinct: None,
12727+
select_modifiers: None,
1272012728
top: None,
1272112729
top_before_distinct: false,
1272212730
projection: vec![
@@ -12860,6 +12868,7 @@ fn parse_connect_by() {
1286012868
select_token: AttachedToken::empty(),
1286112869
optimizer_hint: None,
1286212870
distinct: None,
12871+
select_modifiers: None,
1286312872
top: None,
1286412873
top_before_distinct: false,
1286512874
projection: vec![

0 commit comments

Comments
 (0)