Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

fix(dbapi): avoid running % format with no query parameters - #348

Merged
tswast merged 4 commits into
googleapis:masterfrom
MaxxleLLC:bigquery_issue_346
Oct 29, 2020
Merged

fix(dbapi): avoid running % format with no query parameters#348
tswast merged 4 commits into
googleapis:masterfrom
MaxxleLLC:bigquery_issue_346

Conversation

@HemangChothani

Copy link
Copy Markdown
Contributor

Fixes#346

@HemangChothani
HemangChothani requested review from a team and tswastOctober 28, 2020 08:43
@google-clagoogle-claBot added the cla: yes This human has signed the Contributor License Agreement. label Oct 28, 2020
Comment threadtests/unit/test_dbapi_cursor.py Outdated
def test__format_operation_w_empty_dict(self):
from google.cloud.bigquery.dbapi import cursor

formatted_operation = cursor._format_operation("SELECT 1", {},)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Won't the linter complain about the trailing comma here?

Comment threadtests/unit/test_dbapi_cursor.py Outdated
from google.cloud.bigquery.dbapi import cursor

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

Copy link
Copy Markdown
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'")

@tswasttswast changed the title fix: aviod running %format when no query paramsfix(dbapi): avoid running % format with no query parametersOct 29, 2020
@tswast
tswast merged commit 5dd1a5e into googleapis:masterOct 29, 2020
@tswast

Copy link
Copy Markdown
Contributor

Thanks for the quick fix!

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(dbapi): avoid running % format when no query parameters are passed

2 participants

@HemangChothani@tswast