Skip to content

Commit 79514b7

Browse files
committed
run cargo +nightly fmt
1 parent 66ed8b4 commit 79514b7

File tree

4 files changed

+32
-31
lines changed

4 files changed

+32
-31
lines changed

src/ast/ddl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl fmt::Display for ColumnOption {
187187
on_update,
188188
} => {
189189
write!(f, "REFERENCES {}", foreign_table)?;
190-
if ! referred_columns.is_empty() {
190+
if !referred_columns.is_empty() {
191191
write!(f, " ({})", display_comma_separated(referred_columns))?;
192192
}
193193
if let Some(action) = on_delete {

src/ast/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use std::fmt;
2222

2323
pub use self::data_type::DataType;
2424
pub use self::ddl::{
25-
AlterTableOperation, ColumnDef, ColumnOption, ColumnOptionDef, TableConstraint,
26-
ReferentialAction,
25+
AlterTableOperation, ColumnDef, ColumnOption, ColumnOptionDef, ReferentialAction,
26+
TableConstraint,
2727
};
2828
pub use self::operator::{BinaryOperator, UnaryOperator};
2929
pub use self::query::{

src/parser.rs

+20-17
Original file line numberDiff line numberDiff line change
@@ -1017,28 +1017,23 @@ impl Parser {
10171017
ColumnOption::Unique { is_primary: false }
10181018
} else if self.parse_keyword("REFERENCES") {
10191019
let foreign_table = self.parse_object_name()?;
1020-
let referred_columns =
1021-
self.parse_parenthesized_column_list(Optional)?;
1020+
let referred_columns = self.parse_parenthesized_column_list(Optional)?;
10221021
let mut on_delete = None;
10231022
let mut on_update = None;
10241023
while self.parse_keyword("ON") {
10251024
if self.parse_keyword("DELETE") {
10261025
if on_delete == None {
10271026
on_delete = Some(self.parse_reference_change_action()?);
10281027
} else {
1029-
return self.expected(
1030-
"ON DELETE option not more than once",
1031-
self.peek_token()
1032-
);
1028+
return self
1029+
.expected("ON DELETE option not more than once", self.peek_token());
10331030
}
10341031
} else if self.parse_keyword("UPDATE") {
10351032
if on_update == None {
10361033
on_update = Some(self.parse_reference_change_action()?);
10371034
} else {
1038-
return self.expected(
1039-
"ON UPDATE option not more than once",
1040-
self.peek_token()
1041-
);
1035+
return self
1036+
.expected("ON UPDATE option not more than once", self.peek_token());
10421037
}
10431038
}
10441039
}
@@ -1061,13 +1056,21 @@ impl Parser {
10611056
}
10621057

10631058
pub fn parse_reference_change_action(&mut self) -> Result<ReferentialAction, ParserError> {
1064-
if self.parse_keyword("RESTRICT") { Ok(ReferentialAction::Restrict) }
1065-
else if self.parse_keyword("CASCADE") { Ok(ReferentialAction::Cascade) }
1066-
else if self.parse_keywords(vec!["SET", "NULL"]) { Ok(ReferentialAction::SetNull) }
1067-
else if self.parse_keywords(vec!["NO", "ACTION"]) { Ok(ReferentialAction::NoAction) }
1068-
else if self.parse_keywords(vec!["SET", "DEFAULT"]) { Ok(ReferentialAction::SetDefault) }
1069-
else {
1070-
self.expected("one of RESTRICT, CASCADE, SET NULL, NO ACTION or SET DEFAULT", self.peek_token())
1059+
if self.parse_keyword("RESTRICT") {
1060+
Ok(ReferentialAction::Restrict)
1061+
} else if self.parse_keyword("CASCADE") {
1062+
Ok(ReferentialAction::Cascade)
1063+
} else if self.parse_keywords(vec!["SET", "NULL"]) {
1064+
Ok(ReferentialAction::SetNull)
1065+
} else if self.parse_keywords(vec!["NO", "ACTION"]) {
1066+
Ok(ReferentialAction::NoAction)
1067+
} else if self.parse_keywords(vec!["SET", "DEFAULT"]) {
1068+
Ok(ReferentialAction::SetDefault)
1069+
} else {
1070+
self.expected(
1071+
"one of RESTRICT, CASCADE, SET NULL, NO ACTION or SET DEFAULT",
1072+
self.peek_token(),
1073+
)
10711074
}
10721075
}
10731076

tests/sqlparser_common.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -990,17 +990,15 @@ fn parse_create_table() {
990990
name: "ref2".into(),
991991
data_type: DataType::Int,
992992
collation: None,
993-
options: vec![
994-
ColumnOptionDef {
995-
name: None,
996-
option: ColumnOption::ForeignKey {
997-
foreign_table: ObjectName(vec!["othertable2".into()]),
998-
referred_columns: vec![],
999-
on_delete: Some(ReferentialAction::Cascade),
1000-
on_update: Some(ReferentialAction::NoAction),
1001-
}
1002-
},
1003-
]
993+
options: vec![ColumnOptionDef {
994+
name: None,
995+
option: ColumnOption::ForeignKey {
996+
foreign_table: ObjectName(vec!["othertable2".into()]),
997+
referred_columns: vec![],
998+
on_delete: Some(ReferentialAction::Cascade),
999+
on_update: Some(ReferentialAction::NoAction),
1000+
}
1001+
},]
10041002
}
10051003
]
10061004
);

0 commit comments

Comments
 (0)