Visitar URL original
dbapi: fix paramstyle to 'format' · googleapis/google-cloud-python@498cb57 · GitHub
Skip to content

Commit 498cb57

Browse files
committed
dbapi: fix paramstyle to 'format'
We previously misunderstood the meaning of paramstyle, but really it is what the Cursor expects and not what Spanner expects, since we translate the arguments to be consumable by Spanner, thus the correct paramstyle is 'format'. Fixes #282
1 parent 996b93b commit 498cb57

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎packages/django-google-spanner/spanner/dbapi/__init__.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
# Globals that MUST be defined ###
2424
apilevel = "2.0" # Implements the Python Database API specification 2.0 version.
25-
# '@' is used by Cloud Spanner as the param style but that style isn't listed
26-
# in any of the options https://www.python.org/dev/peps/pep-0249/#paramstyle
27-
# so we are going with a custom named paramstyle.
28-
paramstyle = 'at-named'
25+
# We accept arguments in the format '%s' aka ANSI C print codes.
26+
# as per https://www.python.org/dev/peps/pep-0249/#paramstyle
27+
paramstyle = 'format'
2928
# Threads may not share the module. This is a paranoid threadsafety level, but it is
3029
# necessary for starters to use when debugging failures. Eventually once transactions
3130
# are working properly, we'll update the threadsafety level.

‎packages/django-google-spanner/tests/spanner/dbapi/test_globals.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
class DBAPIGlobalsTests(TestCase):
1313
def test_apilevel(self):
1414
self.assertEqual(apilevel, '2.0', 'We implement PEP-0249 version 2.0')
15-
self.assertEqual(paramstyle, 'at-named', 'Cloud Spanner uses @param')
15+
self.assertEqual(paramstyle, 'format', 'Cloud Spanner uses @param')
1616
self.assertEqual(threadsafety, 0, 'Downgraded to the least concurrency')

0 commit comments

Comments
 (0)