Don't parse ORDER BY as a table alias (8/8)

This commit is contained in:
Nickolay Ponomarev 2019-01-21 00:57:06 +03:00
parent 76ec175d20
commit 50b5724c39
2 changed files with 26 additions and 24 deletions

View file

@ -716,5 +716,5 @@ pub const RESERVED_FOR_TABLE_ALIAS: &'static [&'static str] = &[
WHERE, GROUP, ON, // keyword is 'reserved' in most dialects WHERE, GROUP, ON, // keyword is 'reserved' in most dialects
JOIN, INNER, CROSS, FULL, LEFT, RIGHT, // not reserved in Oracle JOIN, INNER, CROSS, FULL, LEFT, RIGHT, // not reserved in Oracle
NATURAL, USING, // not reserved in Oracle & MSSQL NATURAL, USING, // not reserved in Oracle & MSSQL
// UNION, EXCEPT, INTERSECT, ORDER // TODO add these with tests. ORDER, // UNION, EXCEPT, INTERSECT, // TODO add these with tests.
]; ];

View file

@ -229,9 +229,7 @@ fn parse_not_like() {
#[test] #[test]
fn parse_select_order_by() { fn parse_select_order_by() {
let sql = String::from( fn chk(sql: &str) {
"SELECT id, fname, lname FROM customer WHERE id < 5 ORDER BY lname ASC, fname DESC, id",
);
match verified(&sql) { match verified(&sql) {
ASTNode::SQLSelect { order_by, .. } => { ASTNode::SQLSelect { order_by, .. } => {
assert_eq!( assert_eq!(
@ -255,6 +253,10 @@ fn parse_select_order_by() {
_ => assert!(false), _ => assert!(false),
} }
} }
chk("SELECT id, fname, lname FROM customer WHERE id < 5 ORDER BY lname ASC, fname DESC, id");
// make sure ORDER is not treated as an alias
chk("SELECT id, fname, lname FROM customer ORDER BY lname ASC, fname DESC, id");
}
#[test] #[test]
fn parse_select_order_by_limit() { fn parse_select_order_by_limit() {