-
Notifications
You must be signed in to change notification settings - Fork 693
MySQL: Add support for DEFAULT CHARACTER SET in CREATE DATABASE #2182
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
base: main
Are you sure you want to change the base?
Conversation
Parse MySQL-style [DEFAULT] CHARACTER SET and [DEFAULT] COLLATE options in CREATE DATABASE statements. This adds two new fields to CreateDatabase: default_charset and default_collation. Supports the following syntax variants: - DEFAULT CHARACTER SET [=] charset_name - CHARACTER SET [=] charset_name - DEFAULT CHARSET [=] charset_name - CHARSET [=] charset_name - DEFAULT COLLATE [=] collation_name - COLLATE [=] collation_name
| pub storage_serialization_policy: Option<StorageSerializationPolicy>, | ||
| /// Optional comment attached to the database. | ||
| pub comment: Option<String>, | ||
| /// Optional default character set (MySQL). |
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.
can we include a link to the mysql documentation for the doc comments?
| self.expect_token(&Token::Eq).ok(); | ||
| default_charset = Some(self.parse_identifier()?.value); | ||
| } else if self.parse_keyword(Keyword::COLLATE) { | ||
| self.expect_token(&Token::Eq).ok(); |
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.
can we handle the errors in the calls to expect_token?
| None | ||
| }; | ||
|
|
||
| // Parse MySQL-style [DEFAULT] CHARACTER SET and [DEFAULT] COLLATE options |
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.
Can we move the default_charset and default_collation closer here to the loop? (misread for a second wondering if the values were being previously set elsewhere before the loop)
| // Parse MySQL-style [DEFAULT] CHARACTER SET and [DEFAULT] COLLATE options | ||
| loop { | ||
| let has_default = self.parse_keyword(Keyword::DEFAULT); | ||
| if self.parse_keywords(&[Keyword::CHARACTER, Keyword::SET]) |
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.
| if self.parse_keywords(&[Keyword::CHARACTER, Keyword::SET]) | |
| if default_charset.is_none() && self.parse_keywords(&[Keyword::CHARACTER, Keyword::SET]) |
| { | ||
| self.expect_token(&Token::Eq).ok(); | ||
| default_charset = Some(self.parse_identifier()?.value); | ||
| } else if self.parse_keyword(Keyword::COLLATE) { |
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.
| } else if self.parse_keyword(Keyword::COLLATE) { | |
| } else if default_collation.is_none() && self.parse_keyword(Keyword::COLLATE) { |
Parse MySQL-style [DEFAULT] CHARACTER SET and [DEFAULT] COLLATE options in CREATE DATABASE statements. This adds two new fields to CreateDatabase: default_charset and default_collation.
Supports the following syntax variants: