Skip to content

Commit

Permalink
optimize code logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yukunpeng committed Sep 8, 2023
1 parent 9f06231 commit 0286195
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3894,14 +3894,17 @@ impl<'a> Parser<'a> {
match next_token.token {
Token::Word(w) if w.keyword == Keyword::PRIMARY || w.keyword == Keyword::UNIQUE => {
let is_primary = w.keyword == Keyword::PRIMARY;
let name = if is_primary {
if is_primary {
self.expect_keyword(Keyword::KEY)?;
name
} else if self.parse_keyword(Keyword::KEY) {
self.maybe_parse(|parser| parser.parse_identifier())
} else {
name
};
}

let name = self
.maybe_parse(|parser| {
let _ = parser.parse_keyword(Keyword::KEY);

parser.parse_identifier()
})
.or(name);

let columns = self.parse_parenthesized_column_list(Mandatory, false)?;
Ok(Some(TableConstraint::Unique {
Expand Down

0 comments on commit 0286195

Please sign in to comment.