From: Karsten H. <Kar...@gm...> - 2003-11-04 02:37:51
|
Hi, I am trying to use the IN operator with a tuple of length 1 (no, I can't change to = since I don't know in advance whether the tuple will be of size 1 or longer). If I simply pass the tuple to cursor.execute() it gets unrolled producing one of two errors: if length == 1: select * from ... where ... IN scalar_value; if length > 1: Exception: not all arguments converted If I wrap the tuple in another tuple or list of length 1, eg. (my_tuple,) or [my_tuple] then cursor.execute does recognize that it is supposed to build a list suitable for IN. However, this fails with tuples of size 1: select * from ... where ... IN (scalar_value,); tuples with size > 1 work fine: select * from ... where ... IN (scalar, scalar); I did upgrade to 2.4 since the changelog said something about a fix to the parameter handling concerned with IN operators. That didn't help, unfortunately. And this line in PgSQL -> cursor.execute() seems to be the root of the evil: self.res = self.conn.conn.query(_qstr % parms) What am I to do ? Karsten -- GPG key ID E4071346 @ wwwkeys.pgp.net E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346 |