mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 03:26:37 +03:00
Fixed SQL_IN when getquoted() is called without prepare()
This commit is contained in:
parent
59151886a0
commit
7b1973354f
|
@ -116,9 +116,9 @@ def register_adapter(typ, callable):
|
||||||
# The SQL_IN class is the official adapter for tuples starting from 2.0.6.
|
# The SQL_IN class is the official adapter for tuples starting from 2.0.6.
|
||||||
class SQL_IN(object):
|
class SQL_IN(object):
|
||||||
"""Adapt any iterable to an SQL quotable object."""
|
"""Adapt any iterable to an SQL quotable object."""
|
||||||
|
|
||||||
def __init__(self, seq):
|
def __init__(self, seq):
|
||||||
self._seq = seq
|
self._seq = seq
|
||||||
|
self._conn = None
|
||||||
|
|
||||||
def prepare(self, conn):
|
def prepare(self, conn):
|
||||||
self._conn = conn
|
self._conn = conn
|
||||||
|
@ -127,9 +127,10 @@ class SQL_IN(object):
|
||||||
# this is the important line: note how every object in the
|
# this is the important line: note how every object in the
|
||||||
# list is adapted and then how getquoted() is called on it
|
# list is adapted and then how getquoted() is called on it
|
||||||
pobjs = [adapt(o) for o in self._seq]
|
pobjs = [adapt(o) for o in self._seq]
|
||||||
for obj in pobjs:
|
if self._conn is not None:
|
||||||
if hasattr(obj, 'prepare'):
|
for obj in pobjs:
|
||||||
obj.prepare(self._conn)
|
if hasattr(obj, 'prepare'):
|
||||||
|
obj.prepare(self._conn)
|
||||||
qobjs = [o.getquoted() for o in pobjs]
|
qobjs = [o.getquoted() for o in pobjs]
|
||||||
return b('(') + b(', ').join(qobjs) + b(')')
|
return b('(') + b(', ').join(qobjs) + b(')')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user