Skip to content
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

Support for unquoted hyphenated identifiers on bigquery #1109

Merged
merged 5 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dialect/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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()?;
let table = parser.parse_identifier(false)?;
let alias =
parser.parse_optional_alias(&[Keyword::READ, Keyword::WRITE, Keyword::LOW_PRIORITY])?;
let lock_type = parse_lock_tables_type(parser)?;
Expand Down
4 changes: 2 additions & 2 deletions src/dialect/postgresql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ pub fn parse_comment(parser: &mut Parser) -> Result<Statement, ParserError> {

let (object_type, object_name) = match token.token {
Token::Word(w) if w.keyword == Keyword::COLUMN => {
let object_name = parser.parse_object_name()?;
let object_name = parser.parse_object_name(false)?;
(CommentObject::Column, object_name)
}
Token::Word(w) if w.keyword == Keyword::TABLE => {
let object_name = parser.parse_object_name()?;
let object_name = parser.parse_object_name(false)?;
(CommentObject::Table, object_name)
}
_ => parser.expected("comment object_type", token)?,
Expand Down
6 changes: 3 additions & 3 deletions src/dialect/snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn parse_create_stage(
) -> Result<Statement, ParserError> {
//[ IF NOT EXISTS ]
let if_not_exists = parser.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
let name = parser.parse_object_name()?;
let name = parser.parse_object_name(false)?;
let mut directory_table_params = Vec::new();
let mut file_format = Vec::new();
let mut copy_options = Vec::new();
Expand Down Expand Up @@ -181,7 +181,7 @@ pub fn parse_snowflake_stage_name(parser: &mut Parser) -> Result<ObjectName, Par
}
_ => {
parser.prev_token();
Ok(parser.parse_object_name()?)
Ok(parser.parse_object_name(false)?)
}
}
}
Expand Down Expand Up @@ -219,7 +219,7 @@ pub fn parse_copy_into(parser: &mut Parser) -> Result<Statement, ParserError> {
}
_ => {
parser.prev_token();
from_stage = parser.parse_object_name()?;
from_stage = parser.parse_object_name(false)?;
stage_params = parse_stage_params(parser)?;

// as
Expand Down
18 changes: 9 additions & 9 deletions src/parser/alter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ impl<'a> Parser<'a> {
}

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

let operation = if self.parse_keywords(&[Keyword::ADD, Keyword::MEMBER]) {
let member_name = self.parse_identifier()?;
let member_name = self.parse_identifier(false)?;
AlterRoleOperation::AddMember { member_name }
} else if self.parse_keywords(&[Keyword::DROP, Keyword::MEMBER]) {
let member_name = self.parse_identifier()?;
let member_name = self.parse_identifier(false)?;
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()?;
let role_name = self.parse_identifier(false)?;
AlterRoleOperation::RenameRole { role_name }
} else {
return self.expected("= after WITH NAME ", self.peek_token());
Expand All @@ -63,25 +63,25 @@ impl<'a> Parser<'a> {
}

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

// [ IN DATABASE _`database_name`_ ]
let in_database = if self.parse_keywords(&[Keyword::IN, Keyword::DATABASE]) {
self.parse_object_name().ok()
self.parse_object_name(false).ok()
} else {
None
};

let operation = if self.parse_keyword(Keyword::RENAME) {
if self.parse_keyword(Keyword::TO) {
let role_name = self.parse_identifier()?;
let role_name = self.parse_identifier(false)?;
AlterRoleOperation::RenameRole { role_name }
} else {
return self.expected("TO after RENAME", self.peek_token());
}
// SET
} else if self.parse_keyword(Keyword::SET) {
let config_name = self.parse_object_name()?;
let config_name = self.parse_object_name(false)?;
// FROM CURRENT
if self.parse_keywords(&[Keyword::FROM, Keyword::CURRENT]) {
AlterRoleOperation::Set {
Expand Down Expand Up @@ -117,7 +117,7 @@ impl<'a> Parser<'a> {
in_database,
}
} else {
let config_name = self.parse_object_name()?;
let config_name = self.parse_object_name(false)?;
AlterRoleOperation::Reset {
config_name: ResetConfig::ConfigName(config_name),
in_database,
Expand Down
Loading
Loading