Skip to content

Commit

Permalink
Parser: fix the handling of LIMIT <offset>,<limit>
Browse files Browse the repository at this point in the history
Only handle the punctuation when we already have the LIMIT keyword parsed. From now on IN(a,b,c) condition should not mess with it.
  • Loading branch information
macbre committed Apr 20, 2023
1 parent 5be81fc commit 9dfb994
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sql_metadata/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,9 @@ def limit_and_offset(self) -> Optional[Tuple[int, int]]:
elif token.last_keyword_normalized == "OFFSET":
# OFFSET <offset>
offset = int(token.value)
elif token.previous_token.is_punctuation:
elif token.previous_token.is_punctuation and token.last_keyword_normalized == "LIMIT":
# LIMIT <offset>,<limit>
# enter this condition only when the limit has already been parsed
offset = limit
limit = int(token.value)

Expand Down

0 comments on commit 9dfb994

Please sign in to comment.