summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2005-02-28 15:50:55 +0000
committerFederico Di Gregorio <fog@initd.org>2005-02-28 15:50:55 +0000
commitcd672525e10826231576e6eb5ab256df1bfed72c (patch)
treef6d2add7b330b9c73a950ce6fee0ea9254d12f81 /lib
parent1ec3c837203661efd9441e2509351156b4a53a40 (diff)
downloadpsycopg2-cd672525e10826231576e6eb5ab256df1bfed72c.tar.gz
Adaptation fixes (a lot.)
Diffstat (limited to 'lib')
-rw-r--r--lib/extras.py25
1 files changed, 2 insertions, 23 deletions
diff --git a/lib/extras.py b/lib/extras.py
index 1013bec..1d523d9 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -71,40 +71,19 @@ class DictRow(list):
-class AsIs(object):
- """An adapter that just return the object 'as is'.
-
- psycopg 1.99.9 has some optimizations that make impossible to call adapt()
- without adding some basic adapters externally. This limitation will be
- lifted in a future release. In the meantime you can use the AsIs adapter.
- """
- def __init__(self, obj):
- self.__obj = obj
- def getquoted(self):
- return str(self.__obj)
- def prepare(self, conn):
- pass
- __str__ = getquoted
-
class SQL_IN(object):
"""Adapt any iterable to an SQL quotable object."""
def __init__(self, seq):
self._seq = seq
- def prepare(self, conn):
- pass
-
def getquoted(self):
# this is the important line: note how every object in the
# list is adapted and then how getquoted() is called on it
qobjs = [str(_A(o).getquoted()) for o in self._seq]
return '(' + ', '.join(qobjs) + ')'
-
- __str__ = getquoted
-
+ __str__ = getquoted
+
_RA(tuple, SQL_IN)
-_RA(int, AsIs)
-_RA(float, AsIs)