-
Notifications
You must be signed in to change notification settings - Fork 551
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 single-quoted identifiers #1021
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -620,18 +620,29 @@ impl<'a> Parser<'a> { | |
|
||
let next_token = self.next_token(); | ||
match next_token.token { | ||
Token::Word(w) if self.peek_token().token == Token::Period => { | ||
let mut id_parts: Vec<Ident> = vec![w.to_ident()]; | ||
|
||
while self.consume_token(&Token::Period) { | ||
let next_token = self.next_token(); | ||
match next_token.token { | ||
Token::Word(w) => id_parts.push(w.to_ident()), | ||
Token::Mul => { | ||
return Ok(WildcardExpr::QualifiedWildcard(ObjectName(id_parts))); | ||
} | ||
_ => { | ||
return self.expected("an identifier or a '*' after '.'", next_token); | ||
t @ (Token::Word(_) | Token::SingleQuotedString(_)) => { | ||
if self.peek_token().token == Token::Period { | ||
let mut id_parts: Vec<Ident> = vec![match t { | ||
Token::Word(w) => w.to_ident(), | ||
Token::SingleQuotedString(s) => Ident::with_quote('\'', s), | ||
_ => unreachable!(), // We matched above | ||
}]; | ||
|
||
while self.consume_token(&Token::Period) { | ||
let next_token = self.next_token(); | ||
match next_token.token { | ||
Token::Word(w) => id_parts.push(w.to_ident()), | ||
Token::SingleQuotedString(s) => { | ||
// SQLite has single-quoted identifiers | ||
id_parts.push(Ident::with_quote('\'', s)) | ||
} | ||
Token::Mul => { | ||
return Ok(WildcardExpr::QualifiedWildcard(ObjectName(id_parts))); | ||
} | ||
_ => { | ||
return self | ||
.expected("an identifier or a '*' after '.'", next_token); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -830,6 +841,9 @@ impl<'a> Parser<'a> { | |
let next_token = self.next_token(); | ||
match next_token.token { | ||
Token::Word(w) => id_parts.push(w.to_ident()), | ||
Token::SingleQuotedString(s) => { | ||
id_parts.push(Ident::with_quote('\'', s)) | ||
} | ||
Comment on lines
+844
to
+846
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. This is the most important part |
||
_ => { | ||
return self | ||
.expected("an identifier or a '*' after '.'", next_token); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This we can do later if you want, @alamb , together with support for single-quoted table names.
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.
I actually tried running the test in this PR without this change and it failed, so I am not quite sure what you are proposing to do later
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
This PR supports
select 't'.*
(which is tested) but notselect 't'.my_column
.What I was saying is that if you find that this is not clean, we can remove support for
't'.*
(and the associated part of the test) and re-add it later if/when we add general support for single-quoted table names.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.
I think it is ok -- thank you