On Tue, Apr 11, 2006 at 04:01:02PM -0500, Charles Duffy wrote:
> model.LessonPage.select(model.LessonPage.q.pageNumber ==
> Select(func.MIN(model.LessonPage.q.pageNumber),
> where=model.LessonPage.q.pageNumber > page.pageNumber))
>
> ...for which the following SQL is generated:
>
> SELECT lesson_page.id, lesson_page.child_name, lesson_page.title,
> lesson_page.page_number, lesson_page.lesson_id FROM lesson_page WHERE
> (lesson_page.page_number = SELECT MIN(lesson_page.page_number) FROM
> lesson_page WHERE (lesson_page.page_number > 1))
>
> This is invalid, however, and leads to a syntax error on account of the
> subselect not having parenthesis around it. If I paste the query into
> SQLite and add an extra set of parenthesis (from just before the nested
> SELECT to the end of the statement), all is well.
Like this?
SELECT lesson_page.id, lesson_page.child_name, lesson_page.title,
lesson_page.page_number, lesson_page.lesson_id FROM lesson_page WHERE
(lesson_page.page_number = (SELECT MIN(lesson_page.page_number) FROM
lesson_page WHERE (lesson_page.page_number > 1)))
> Is there a mechanism by which I can ask SQLObject to add these parens?
SQLObject generates query strings in dbconnection.py and sqlbuilder.py
modules. I think the only way to fix this would be to always add parens
whatever parameters are, Select() or not.
> Alternately, is the SQLite binding for SQLObject broken?
It is not. :)
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss