mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
Support MySQL style LIMIT X, Y
(#415)
This commit is contained in:
parent
2072ef2031
commit
d7f4f1aac9
2 changed files with 13 additions and 0 deletions
|
@ -2605,6 +2605,11 @@ impl<'a> Parser<'a> {
|
|||
if offset.is_none() && self.parse_keyword(Keyword::OFFSET) {
|
||||
offset = Some(self.parse_offset()?)
|
||||
}
|
||||
|
||||
if offset.is_none() && self.consume_token(&Token::Comma) {
|
||||
// mysql style LIMIT 10, offset 5
|
||||
offset = Some(self.parse_offset()?)
|
||||
}
|
||||
}
|
||||
|
||||
let fetch = if self.parse_keyword(Keyword::FETCH) {
|
||||
|
|
|
@ -1269,6 +1269,14 @@ fn parse_limit_accepts_all() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_limit_my_sql_syntax() {
|
||||
one_statement_parses_to(
|
||||
"SELECT id, fname, lname FROM customer LIMIT 5, 10",
|
||||
"SELECT id, fname, lname FROM customer LIMIT 5 OFFSET 10",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_cast() {
|
||||
let sql = "SELECT CAST(id AS BIGINT) FROM customer";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue