sqlparse
sqlparse copied to clipboard
Token matching generates an exception when index is None
Describe the bug
Using token_matching with index None generates an TypeError exception
To Reproduce Executing the following code
import sqlparse
p = sqlparse.parse("SELECT id FROM table")[0]
p.token_matching([lambda x: isinstance(x, sqlparse.sql.Token)], None)
generates an exception
Traceback (most recent call last):
File "/repositories/github/sqlparse/t.py", line 4, in <module>
p.token_matching(lambda x: isinstance(x, sqlparse.sql.Token), None)
File "/repositories/github/sqlparse/sqlparse/sql.py", line 277, in token_matching
return self._token_matching(funcs, idx)[1]
TypeError: 'NoneType' object is not subscriptable
Expected behavior
token_matching should return None
Versions (please complete the following information):
- Python: 3.9.18
- sqlparse: git commit f101546d