Merge pull request #26 from virattara/fix_order_limit

fix for queries with both order by and limit
This commit is contained in:
Andy Grove 2018-10-14 10:13:22 -06:00 committed by GitHub
commit 633aeb9162
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 13 deletions

View file

@ -1173,23 +1173,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));