Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/cloud/bigquery/dbapi/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def _format_operation(operation, parameters=None):
if a parameter used in the operation is not found in the
``parameters`` argument.
"""
if parameters is None:
if parameters is None or len(parameters) == 0:
return operation

if isinstance(parameters, collections_abc.Mapping):
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_dbapi_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,9 @@ def test__format_operation_w_too_short_sequence(self):
"SELECT %s, %s;",
("hello",),
)

def test__format_operation_w_empty_dict(self):
from google.cloud.bigquery.dbapi import cursor

formatted_operation = cursor._format_operation("SELECT 1", {})
self.assertEqual(formatted_operation, "SELECT 1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, let's put a % sign in this string to catch the reported error

Suggested change
self.assertEqual(formatted_operation, "SELECT 1")
self.assertEqual(formatted_operation, "SELECT '%f'")