Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added release note about percent literals in cursor.execute

Thanks Aymeric Augustin for noticing the omission and Tim Graham
for the text review.
Fixes #9055 (again).
  • Loading branch information...
commit 975c5afdb5a0c2f9f61f9faecf8dbd928c4996b7 1 parent 2322906
Claude Paroz authored April 05, 2013

Showing 1 changed file with 18 additions and 0 deletions. Show diff stats Hide diff stats

  1. 18  docs/releases/1.6.txt
18  docs/releases/1.6.txt
@@ -392,6 +392,24 @@ If you do not apply this change, the behaviour is unchanged: on MySQL, IPv6
392 392
 addresses are silently truncated; on Oracle, an exception is generated. No
393 393
 database change is needed for SQLite or PostgreSQL databases.
394 394
 
  395
+Percent literals in ``cursor.execute`` queries
  396
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  397
+
  398
+When you are running raw SQL queries through the
  399
+:ref:`cursor.execute <executing-custom-sql>` method, the rule about doubling
  400
+percent literals (``%``) inside the query has been unified. Past behavior
  401
+depended on the database backend. Now, across all backends, you only need to
  402
+double literal percent characters if you are also providing replacement
  403
+parameters. For example::
  404
+
  405
+    # No parameters, no percent doubling
  406
+    cursor.execute("SELECT foo FROM bar WHERE baz = '30%'")
  407
+
  408
+    # Parameters passed, non-placeholders have to be doubled
  409
+    cursor.execute("SELECT foo FROM bar WHERE baz = '30%%' and id = %s", [self.id])
  410
+
  411
+``SQLite`` users need to check and update such queries.
  412
+
395 413
 Miscellaneous
396 414
 ~~~~~~~~~~~~~
397 415
 

0 notes on commit 975c5af

Please sign in to comment.
Something went wrong with that request. Please try again.