Skip to content

Commit

Permalink
Fix the parsing result for the special double number (#1621)
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmedal authored Dec 28, 2024
1 parent 6daa4b0 commit d0d4153
Show file tree
Hide file tree
Showing 7 changed files with 410 additions and 265 deletions.
2 changes: 1 addition & 1 deletion src/dialect/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn parse_lock_tables(parser: &mut Parser) -> Result<Statement, ParserError> {

// tbl_name [[AS] alias] lock_type
fn parse_lock_table(parser: &mut Parser) -> Result<LockTable, ParserError> {
let table = parser.parse_identifier(false)?;
let table = parser.parse_identifier()?;
let alias =
parser.parse_optional_alias(&[Keyword::READ, Keyword::WRITE, Keyword::LOW_PRIORITY])?;
let lock_type = parse_lock_tables_type(parser)?;
Expand Down
2 changes: 1 addition & 1 deletion src/dialect/postgresql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub fn parse_create_type_as_enum(
return parser.expected("'(' after CREATE TYPE AS ENUM", parser.peek_token());
}

let labels = parser.parse_comma_separated0(|p| p.parse_identifier(false), Token::RParen)?;
let labels = parser.parse_comma_separated0(|p| p.parse_identifier(), Token::RParen)?;
parser.expect_token(&Token::RParen)?;

Ok(Statement::CreateType {
Expand Down
8 changes: 4 additions & 4 deletions src/dialect/snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub fn parse_create_table(
parser.expect_keyword_is(Keyword::BY)?;
parser.expect_token(&Token::LParen)?;
let cluster_by = Some(WrappedCollection::Parentheses(
parser.parse_comma_separated(|p| p.parse_identifier(false))?,
parser.parse_comma_separated(|p| p.parse_identifier())?,
));
parser.expect_token(&Token::RParen)?;

Expand Down Expand Up @@ -369,7 +369,7 @@ pub fn parse_create_table(
let policy = parser.parse_object_name(false)?;
parser.expect_keyword_is(Keyword::ON)?;
parser.expect_token(&Token::LParen)?;
let columns = parser.parse_comma_separated(|p| p.parse_identifier(false))?;
let columns = parser.parse_comma_separated(|p| p.parse_identifier())?;
parser.expect_token(&Token::RParen)?;

builder =
Expand Down Expand Up @@ -887,10 +887,10 @@ fn parse_column_policy_property(
parser: &mut Parser,
with: bool,
) -> Result<ColumnPolicyProperty, ParserError> {
let policy_name = parser.parse_identifier(false)?;
let policy_name = parser.parse_identifier()?;
let using_columns = if parser.parse_keyword(Keyword::USING) {
parser.expect_token(&Token::LParen)?;
let columns = parser.parse_comma_separated(|p| p.parse_identifier(false))?;
let columns = parser.parse_comma_separated(|p| p.parse_identifier())?;
parser.expect_token(&Token::RParen)?;
Some(columns)
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/parser/alter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ impl Parser<'_> {
///
/// [PostgreSQL](https://www.postgresql.org/docs/current/sql-alterpolicy.html)
pub fn parse_alter_policy(&mut self) -> Result<Statement, ParserError> {
let name = self.parse_identifier(false)?;
let name = self.parse_identifier()?;
self.expect_keyword_is(Keyword::ON)?;
let table_name = self.parse_object_name(false)?;

if self.parse_keyword(Keyword::RENAME) {
self.expect_keyword_is(Keyword::TO)?;
let new_name = self.parse_identifier(false)?;
let new_name = self.parse_identifier()?;
Ok(Statement::AlterPolicy {
name,
table_name,
Expand Down Expand Up @@ -100,17 +100,17 @@ impl Parser<'_> {
}

fn parse_mssql_alter_role(&mut self) -> Result<Statement, ParserError> {
let role_name = self.parse_identifier(false)?;
let role_name = self.parse_identifier()?;

let operation = if self.parse_keywords(&[Keyword::ADD, Keyword::MEMBER]) {
let member_name = self.parse_identifier(false)?;
let member_name = self.parse_identifier()?;
AlterRoleOperation::AddMember { member_name }
} else if self.parse_keywords(&[Keyword::DROP, Keyword::MEMBER]) {
let member_name = self.parse_identifier(false)?;
let member_name = self.parse_identifier()?;
AlterRoleOperation::DropMember { member_name }
} else if self.parse_keywords(&[Keyword::WITH, Keyword::NAME]) {
if self.consume_token(&Token::Eq) {
let role_name = self.parse_identifier(false)?;
let role_name = self.parse_identifier()?;
AlterRoleOperation::RenameRole { role_name }
} else {
return self.expected("= after WITH NAME ", self.peek_token());
Expand All @@ -126,7 +126,7 @@ impl Parser<'_> {
}

fn parse_pg_alter_role(&mut self) -> Result<Statement, ParserError> {
let role_name = self.parse_identifier(false)?;
let role_name = self.parse_identifier()?;

// [ IN DATABASE _`database_name`_ ]
let in_database = if self.parse_keywords(&[Keyword::IN, Keyword::DATABASE]) {
Expand All @@ -137,7 +137,7 @@ impl Parser<'_> {

let operation = if self.parse_keyword(Keyword::RENAME) {
if self.parse_keyword(Keyword::TO) {
let role_name = self.parse_identifier(false)?;
let role_name = self.parse_identifier()?;
AlterRoleOperation::RenameRole { role_name }
} else {
return self.expected("TO after RENAME", self.peek_token());
Expand Down
Loading

0 comments on commit d0d4153

Please sign in to comment.