[SQL-CVS] r1109 - SQLObject/trunk/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-10-12 16:21:15
|
Author: ianb
Date: 2005-10-12 16:20:59 +0000 (Wed, 12 Oct 2005)
New Revision: 1109
Modified:
SQLObject/trunk/sqlobject/sresults.py
Log:
Filter should respect queries written as strings (which RelatedJoin also happens to use, and is necessary when using SQLRelatedJoin with .filter()). Also, ignore arguments of None, as this represents an empty query that should match anything (using the same semantics as .select())
Modified: SQLObject/trunk/sqlobject/sresults.py
===================================================================
--- SQLObject/trunk/sqlobject/sresults.py 2005-10-12 14:46:53 UTC (rev 1108)
+++ SQLObject/trunk/sqlobject/sresults.py 2005-10-12 16:20:59 UTC (rev 1109)
@@ -91,7 +91,13 @@
self.clauseTables, **self.ops)
def filter(self, filter_clause):
- return self.newClause(sqlbuilder.AND(self.clause, filter_clause))
+ if filter_clause is None:
+ # None doesn't filter anything, it's just a no-op:
+ return self
+ clause = self.clause
+ if isinstance(clause, (str, unicode)):
+ clause = sqlbuilder.SQLConstant('(%s)' % self.clause)
+ return self.newClause(sqlbuilder.AND(clause, filter_clause))
def __getitem__(self, value):
if type(value) is type(slice(1)):
|