Skip to content

Commit 202464a

Browse files
authored
Merge pull request #68 from ivanceras/master
Add LIMIT as RESERVED_FOR_TABLE_ALIAS
2 parents d80f9f3 + 24f3d06 commit 202464a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/dialect/keywords.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ pub const RESERVED_FOR_TABLE_ALIAS: &[&str] = &[
396396
// Reserved as both a table and a column alias:
397397
WITH, SELECT, WHERE, GROUP, ORDER, UNION, EXCEPT, INTERSECT,
398398
// Reserved only as a table alias in the `FROM`/`JOIN` clauses:
399-
ON, JOIN, INNER, CROSS, FULL, LEFT, RIGHT, NATURAL, USING,
399+
ON, JOIN, INNER, CROSS, FULL, LEFT, RIGHT, NATURAL, USING, LIMIT,
400400
];
401401

402402
/// Can't be used as a column alias, so that `SELECT <expr> alias`

tests/sqlparser_common.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ fn parse_simple_select() {
124124
assert_eq!(Some(ASTNode::SQLValue(Value::Long(5))), select.limit);
125125
}
126126

127+
#[test]
128+
fn parse_select_with_limit_but_no_where() {
129+
let sql = "SELECT id, fname, lname FROM customer LIMIT 5";
130+
let select = verified_only_select(sql);
131+
assert_eq!(false, select.distinct);
132+
assert_eq!(3, select.projection.len());
133+
let select = verified_query(sql);
134+
assert_eq!(Some(ASTNode::SQLValue(Value::Long(5))), select.limit);
135+
}
136+
127137
#[test]
128138
fn parse_select_distinct() {
129139
let sql = "SELECT DISTINCT name FROM customer";

0 commit comments

Comments
 (0)