Hi
Here is a patch I recently wrote that makes makes it easier to write code
that constructs queries dynamically:
queries = []
if some_condition:
queries.append(...)
...
Table.select(AND(queries))
AND (and OR too) will now do the correct thing if there's 0, 1 or several
argument(s) supplied.
Johan
Index: external/sqlobject/sqlbuilder.py
===================================================================
--- external/sqlobject/sqlbuilder.py (revisão 5549)
+++ external/sqlobject/sqlbuilder.py (cópia de trabalho)
@@ -596,6 +596,8 @@
return '%s DESC' % sqlrepr(self.expr, db)
def AND(*ops):
+ if not ops:
+ return
op1 = ops[0]
ops = ops[1:]
if ops:
@@ -604,6 +606,8 @@
return op1
def OR(*ops):
+ if not ops:
+ return
op1 = ops[0]
ops = ops[1:]
if ops:
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss