[SQL-CVS] r2798 - in SQLObject/trunk/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2007-07-25 19:01:49
|
Author: phd
Date: 2007-07-25 13:01:44 -0600 (Wed, 25 Jul 2007)
New Revision: 2798
Modified:
SQLObject/trunk/sqlobject/converters.py
SQLObject/trunk/sqlobject/tests/test_converters.py
Log:
Changed string quoting style for PostgreSQL and MySQL from \' to ''.
Modified: SQLObject/trunk/sqlobject/converters.py
===================================================================
--- SQLObject/trunk/sqlobject/converters.py 2007-07-25 19:00:59 UTC (rev 2797)
+++ SQLObject/trunk/sqlobject/converters.py 2007-07-25 19:01:44 UTC (rev 2798)
@@ -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/trunk/sqlobject/tests/test_converters.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_converters.py 2007-07-25 19:00:59 UTC (rev 2797)
+++ SQLObject/trunk/sqlobject/tests/test_converters.py 2007-07-25 19:01:44 UTC (rev 2798)
@@ -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():
|