Skip to content

Commit 53b326c

Browse files
ekorchmarandialbrecht
authored andcommitted
docs: clarify behavior of Token.match method
1 parent c7e7984 commit 53b326c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

sqlparse/sql.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ def flatten(self):
8989
def match(self, ttype, values, regex=False):
9090
"""Checks whether the token matches the given arguments.
9191
92-
*ttype* is a token type. If this token doesn't match the given token
93-
type.
94-
*values* is a list of possible values for this token. The values
95-
are OR'ed together so if only one of the values matches ``True``
96-
is returned. Except for keyword tokens the comparison is
97-
case-sensitive. For convenience it's OK to pass in a single string.
98-
If *regex* is ``True`` (default is ``False``) the given values are
99-
treated as regular expressions.
92+
*ttype* is a token type as defined in `sqlparse.tokens`. If it does
93+
not match, ``False`` is returned.
94+
*values* is a list of possible values for this token. For match to be
95+
considered valid, the token value needs to be in this list. For tokens
96+
of type ``Keyword`` the comparison is case-insensitive. For
97+
convenience, a single value can be given passed as a string.
98+
If *regex* is ``True``, the given values are treated as regular
99+
expressions. Partial matches are allowed. Defaults to ``False``.
100100
"""
101101
type_matched = self.ttype is ttype
102102
if not type_matched or values is None:
@@ -106,7 +106,7 @@ def match(self, ttype, values, regex=False):
106106
values = (values,)
107107

108108
if regex:
109-
# TODO: Add test for regex with is_keyboard = false
109+
# TODO: Add test for regex with is_keyword = false
110110
flag = re.IGNORECASE if self.is_keyword else 0
111111
values = (re.compile(v, flag) for v in values)
112112

0 commit comments

Comments
 (0)