mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-06 15:28:02 +00:00
fix for queries with both order by and limit
This commit is contained in:
parent
335607f6bb
commit
9f47e8ac94
2 changed files with 37 additions and 13 deletions
|
@ -1166,23 +1166,20 @@ impl Parser {
|
|||
// look for optional ASC / DESC specifier
|
||||
let asc = match self.peek_token() {
|
||||
Some(Token::Keyword(k)) => {
|
||||
self.next_token(); // consume it
|
||||
match k.to_uppercase().as_ref() {
|
||||
"ASC" => true,
|
||||
"DESC" => false,
|
||||
_ => {
|
||||
return parser_err!(format!(
|
||||
"Invalid modifier for ORDER BY expression: {:?}",
|
||||
k
|
||||
))
|
||||
}
|
||||
"ASC" => {
|
||||
self.next_token();
|
||||
true
|
||||
},
|
||||
"DESC" => {
|
||||
self.next_token();
|
||||
false
|
||||
},
|
||||
_ => true
|
||||
}
|
||||
}
|
||||
Some(Token::Comma) => true,
|
||||
Some(other) => {
|
||||
return parser_err!(format!("Unexpected token after ORDER BY expr: {:?}", other))
|
||||
}
|
||||
None => true,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
expr_list.push(SQLOrderByExpr::new(Box::new(expr), asc));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue