From 165095be506dd1b0d4205ca4f240ce38957424da Mon Sep 17 00:00:00 2001 From: Andreas Albrecht Date: Mon, 6 Jan 2020 17:36:01 +0100 Subject: Stabilize grouping engine when parsing invalid SQL statements. It's just to make sure, that the comparison returns a valid result when feed with invalid SQL statements. --- sqlparse/engine/grouping.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sqlparse/engine') diff --git a/sqlparse/engine/grouping.py b/sqlparse/engine/grouping.py index 4f07bc5..3f06e8a 100644 --- a/sqlparse/engine/grouping.py +++ b/sqlparse/engine/grouping.py @@ -254,9 +254,9 @@ def group_operator(tlist): def valid(token): return imt(token, i=sqlcls, t=ttypes) \ - or token.match( + or (token and token.match( T.Keyword, - ('CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP')) + ('CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP'))) def post(tlist, pidx, tidx, nidx): tlist[tidx].ttype = T.Operator -- cgit v1.2.1