Author: phd
Date: 2007-07-25 13:00:59 -0600 (Wed, 25 Jul 2007)
New Revision: 2797
Modified:
SQLObject/branches/0.9/docs/News.txt
SQLObject/branches/0.9/sqlobject/converters.py
SQLObject/branches/0.9/sqlobject/tests/test_converters.py
Log:
Changed string quoting style for PostgreSQL and MySQL from \' to ''.
Modified: SQLObject/branches/0.9/docs/News.txt
===================================================================
--- SQLObject/branches/0.9/docs/News.txt 2007-07-25 19:00:15 UTC (rev 2796)
+++ SQLObject/branches/0.9/docs/News.txt 2007-07-25 19:00:59 UTC (rev 2797)
@@ -263,6 +263,11 @@
* Fixed a bug in converting date/time for years < 1000 (time.strptime()
requires exactly 4 digits for %Y, hence a year < 1000 must be 0-padded).
+Other Changes
+-------------
+
+* Changed string quoting style for PostgreSQL and MySQL from \' to ''.
+
SQLObject 0.7.7
===============
Modified: SQLObject/branches/0.9/sqlobject/converters.py
===================================================================
--- SQLObject/branches/0.9/sqlobject/converters.py 2007-07-25 19:00:15 UTC (rev 2796)
+++ SQLObject/branches/0.9/sqlobject/converters.py 2007-07-25 19:00:59 UTC (rev 2797)
@@ -55,14 +55,14 @@
########################################
sqlStringReplace = [
+ ("'", "''"),
('\\', '\\\\'),
- ("'", "\\'"),
('\000', '\\0'),
('\b', '\\b'),
('\n', '\\n'),
('\r', '\\r'),
('\t', '\\t'),
- ]
+]
def isoStr(val):
"""
@@ -109,10 +109,10 @@
elif isinstance(value, buffer_type):
value = str(value)
- if db in ('mysql', 'postgres'):
+ if db == 'postgres':
for orig, repl in sqlStringReplace:
value = value.replace(orig, repl)
- elif db in ('sqlite', 'firebird', 'sybase', 'maxdb', 'mssql'):
+ elif db in ('sqlite', 'mysql', 'firebird', 'sybase', 'maxdb', 'mssql'):
value = value.replace("'", "''")
else:
assert 0, "Database %s unknown" % db
Modified: SQLObject/branches/0.9/sqlobject/tests/test_converters.py
===================================================================
--- SQLObject/branches/0.9/sqlobject/tests/test_converters.py 2007-07-25 19:00:15 UTC (rev 2796)
+++ SQLObject/branches/0.9/sqlobject/tests/test_converters.py 2007-07-25 19:00:59 UTC (rev 2797)
@@ -55,7 +55,7 @@
assert sqlrepr('A String\000Another', 'postgres') == "'A String\\0Another'"
def test_string_():
- assert sqlrepr('A String\'Another', 'postgres') == "'A String\\'Another'"
+ assert sqlrepr('A String\tAnother', 'postgres') == "'A String\\tAnother'"
assert sqlrepr('A String\'Another', 'firebird') == "'A String''Another'"
def test_simple_unicode():
|