googleapis / python-spanner

Apache License 2.0
134 stars 84 forks source link

[spanner_dbapi] While running a query that contains just comment, it causes an IndexError exception #1178

Closed bhatt4982 closed 1 week ago

bhatt4982 commented 1 month ago

In Cursor -> execute(), while running a query that contains just comment, it causes an IndexError exception

Example query>> --comment Error: IndexError: tuple index out of range File "/Users/sanjeevbhatt/github/python-spanner-dev/google/cloud/spanner_dbapi/parse_utils.py", line 354, in ensure_where_clause if any(isinstance(token, sqlparse.sql.Where) for token in sqlparse.parse(sql)[0]): Note: Go cli returns “Error: Invalid Statement”

Environment details

Code example

query = "--comment" cursor.execute(query)

Stack trace

Error: IndexError: tuple index out of range File "/Users/sanjeevbhatt/github/python-spanner-dev/google/cloud/spanner_dbapi/parse_utils.py", line 354, in ensure_where_clause if any(isinstance(token, sqlparse.sql.Where) for token in sqlparse.parse(sql)[0]):

Thanks!

bhatt4982 commented 1 month ago

We should return ProgrammingError - Invalid statement in this scenario