Skip to content

Commit cffc8bb

Browse files
parser: flatten ALTER TABLE SET branch chain
Refactor parse_alter_table_operation to collapse a nested else-if structure into a direct else-if chain for PostgreSQL/GEDERIC SET LOGGED and SET UNLOGGED handling. This is a no-behavior-change control-flow cleanup aligned with Clippy's collapsible_else_if lint under -D warnings.
1 parent 1e7e4c7 commit cffc8bb

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/parser/mod.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10371,32 +10371,30 @@ impl<'a> Parser<'a> {
1037110371
} else if self.parse_keywords(&[Keyword::VALIDATE, Keyword::CONSTRAINT]) {
1037210372
let name = self.parse_identifier()?;
1037310373
AlterTableOperation::ValidateConstraint { name }
10374+
} else if dialect_of!(self is PostgreSqlDialect | GenericDialect)
10375+
&& self.parse_keywords(&[Keyword::SET, Keyword::LOGGED])
10376+
{
10377+
AlterTableOperation::SetLogged
10378+
} else if dialect_of!(self is PostgreSqlDialect | GenericDialect)
10379+
&& self.parse_keywords(&[Keyword::SET, Keyword::UNLOGGED])
10380+
{
10381+
AlterTableOperation::SetUnlogged
1037410382
} else {
10375-
if dialect_of!(self is PostgreSqlDialect | GenericDialect)
10376-
&& self.parse_keywords(&[Keyword::SET, Keyword::LOGGED])
10377-
{
10378-
AlterTableOperation::SetLogged
10379-
} else if dialect_of!(self is PostgreSqlDialect | GenericDialect)
10380-
&& self.parse_keywords(&[Keyword::SET, Keyword::UNLOGGED])
10381-
{
10382-
AlterTableOperation::SetUnlogged
10383+
let mut options =
10384+
self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
10385+
if !options.is_empty() {
10386+
AlterTableOperation::SetTblProperties {
10387+
table_properties: options,
10388+
}
1038310389
} else {
10384-
let mut options =
10385-
self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
10390+
options = self.parse_options(Keyword::SET)?;
1038610391
if !options.is_empty() {
10387-
AlterTableOperation::SetTblProperties {
10388-
table_properties: options,
10389-
}
10392+
AlterTableOperation::SetOptionsParens { options }
1039010393
} else {
10391-
options = self.parse_options(Keyword::SET)?;
10392-
if !options.is_empty() {
10393-
AlterTableOperation::SetOptionsParens { options }
10394-
} else {
10395-
return self.expected_ref(
10396-
"ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, SET, or SET TBLPROPERTIES after ALTER TABLE",
10397-
self.peek_token_ref(),
10398-
);
10399-
}
10394+
return self.expected_ref(
10395+
"ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, SET, or SET TBLPROPERTIES after ALTER TABLE",
10396+
self.peek_token_ref(),
10397+
);
1040010398
}
1040110399
}
1040210400
};

0 commit comments

Comments
 (0)