From: SourceForge.net <no...@so...> - 2007-05-01 06:04:16
|
Bugs item #1672884, was opened at 2007-03-03 21:34 Message generated for change (Comment added) made by andrewmcnamara You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=1672884&group_id=16528 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Larry Hastings (lhastings) Assigned to: Nobody/Anonymous (nobody) Summary: "where x in %s" failes with single-element tuple Initial Comment: This: db.execute("delete from table where index in %s", ((1, 2, 3),) ) works fine. But this: db.execute("delete from table where index in %s", ((1,),) ) fails with a syntax error. It's because PyPgSQL renders the arguments into the command, so the command fed into PostgreSQL becomes delete from table where index in (1,); and PostgreSQL's parser doesn't like a one-element tuple like that. I suspect the fix is: notice when rendering a one-element tuple, and somehow remove or prevent the comma. ---------------------------------------------------------------------- Comment By: Andrew McNamara (andrewmcnamara) Date: 2007-05-01 16:04 Message: Logged In: YES user_id=698599 Originator: NO In PgSQL.py, the function _quote() is responsible for this. For example: >>> from pyPgSQL import PgSQL >>> PgSQL._quote((1,)) '(1)' ---------------------------------------------------------------------- Comment By: Larry Hastings (lhastings) Date: 2007-05-01 15:38 Message: Logged In: YES user_id=364875 Originator: YES I'm using 2.5.1, and I definitely saw the problem. Where in the code does it handle this case? ---------------------------------------------------------------------- Comment By: Andrew McNamara (andrewmcnamara) Date: 2007-04-30 18:04 Message: Logged In: YES user_id=698599 Originator: NO You might want to check that you're using an up-to-date version of pyPgSQL - I seem to remember this being fixed in 2.4. I use IN queries extensively in my apps, and I haven't had a complaint about this problem for some time. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=1672884&group_id=16528 |