> I am backing out this patch. Please resubmit with this corrected. Thanks.

>
> I am running Python 1.5.

Therein lies the problem... :)

Since it appears you have the requirement of supporting old python
versions, attached is just the pgdb.py part of the patch (with a fix for
DateTime handling). It has the same functionality but certainly won't be
quite as fast. Given the absence of _PyString_Join in python1.5, it's a
pain to get the C variants working for all versions. The pgdb.py patch
does leaves the hooks in, should someone wish to do the optimization at a
later point.

Elliot Lee
This commit is contained in:
Bruce Momjian 2002-03-19 02:47:57 +00:00
parent a7ade2bb6b
commit d3337c6e3f
1 changed files with 30 additions and 22 deletions

View File

@ -260,7 +260,13 @@ class pgdbCursor:
pass pass
def _quote(x): try:
_quote = _pg.quote_fast
_quoteparams = _pg.quoteparams_fast
except (NameError, AttributeError):
def _quote(x):
if type(x) == DateTime.DateTimeType:
x = str(x)
if type(x) == types.StringType: if type(x) == types.StringType:
x = "'" + string.replace( x = "'" + string.replace(
string.replace(str(x), '\\', '\\\\'), "'", "''") + "'" string.replace(str(x), '\\', '\\\\'), "'", "''") + "'"
@ -269,6 +275,8 @@ def _quote(x):
pass pass
elif x is None: elif x is None:
x = 'NULL' x = 'NULL'
elif type(x) in (types.ListType, types.TupleType):
x = '(%s)' % string.join(map(lambda x: str(_quote(x)), x), ',')
elif hasattr(x, '__pg_repr__'): elif hasattr(x, '__pg_repr__'):
x = x.__pg_repr__() x = x.__pg_repr__()
else: else:
@ -276,7 +284,7 @@ def _quote(x):
return x return x
def _quoteparams(s, params): def _quoteparams(s, params):
if hasattr(params, 'has_key'): if hasattr(params, 'has_key'):
x = {} x = {}
for k, v in params.items(): for k, v in params.items():