mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-11 14:32:04 +00:00
[mssql] Support single-quoted column aliases
This commit is contained in:
parent
d0a782d8cc
commit
93c9000102
3 changed files with 30 additions and 7 deletions
|
@ -1167,15 +1167,18 @@ impl Parser {
|
|||
{
|
||||
Ok(Some(w.as_sql_ident()))
|
||||
}
|
||||
ref not_an_ident if after_as => parser_err!(format!(
|
||||
"Expected an identifier after AS, got {:?}",
|
||||
not_an_ident
|
||||
)),
|
||||
Some(_not_an_ident) => {
|
||||
self.prev_token();
|
||||
// MSSQL supports single-quoted strings as aliases for columns
|
||||
// We accept them as table aliases too, although MSSQL does not.
|
||||
Some(Token::SingleQuotedString(ref s)) => Ok(Some(format!("'{}'", s))),
|
||||
not_an_ident => {
|
||||
if after_as {
|
||||
return self.expected("an identifier after AS", not_an_ident);
|
||||
}
|
||||
if not_an_ident.is_some() {
|
||||
self.prev_token();
|
||||
}
|
||||
Ok(None) // no alias found
|
||||
}
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue