-
Notifications
You must be signed in to change notification settings - Fork 605
Add support for MySQL auto_increment offset #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3550,6 +3550,17 @@ impl<'a> Parser<'a> { | |
None | ||
}; | ||
|
||
let autoincrement_offset = if self.parse_keyword(Keyword::AUTO_INCREMENT) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://dev.mysql.com/doc/refman/8.0/en/create-table.html I got super confused for a moment because
Or also as part of the column definition
Which SQLParser already handles |
||
let _ = self.consume_token(&Token::Eq); | ||
let next_token = self.next_token(); | ||
match next_token.token { | ||
Token::Number(s, _) => Some(s.parse::<u32>().expect("literal int")), | ||
_ => self.expected("literal int", next_token)?, | ||
} | ||
} else { | ||
None | ||
}; | ||
|
||
let order_by = if self.parse_keywords(&[Keyword::ORDER, Keyword::BY]) { | ||
if self.consume_token(&Token::LParen) { | ||
let columns = if self.peek_token() != Token::RParen { | ||
|
@@ -3631,6 +3642,7 @@ impl<'a> Parser<'a> { | |
.clone_clause(clone) | ||
.engine(engine) | ||
.comment(comment) | ||
.autoincrement_offset(autoincrement_offset) | ||
.order_by(order_by) | ||
.default_charset(default_charset) | ||
.collation(collation) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason to use a different style than the original
auto_increment
? I wonder if you considered:?
If so can you explain why you chose this way?
I was thinking that following the exisiting convention would make the relevant code / field easier to search for (aka you can search for
auto_increment
in the code to see howauto_increment
inSQL
would be parsed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alamb Thanks for the feedback.
No specific reason, your suggestion of more closely following convention is a better option I think, so I updated the PR