dabo Commit
Revision 5180
Date: 2009-04-18 06:55:13 -0700 (Sat, 18 Apr 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5180
Changed:
U trunk/dabo/biz/dBizobj.py
U trunk/dabo/db/dCursorMixin.py
Log:
Revamped the code for determining the alias used in a child filter. Previously
the bizobj's DataSource was used, which incorrectly assumed that that would be
the correct alias. This addresses the issue (Trac #1228) raised by Sibylle
Koczian.
Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py 2009-04-15 11:03:10 UTC (rev 5179)
+++ trunk/dabo/biz/dBizobj.py 2009-04-18 13:55:13 UTC (rev 5180)
@@ -915,27 +915,21 @@
current PK value. This will add the appropriate WHERE clause to
filter the child records. If the parent is a new, unsaved
record, or if
there is no parent record, there cannot be any child records
saved yet,
- so an empty query is built.
+ so an empty query is built.
"""
- currWhere = self.getWhereClause()
if self.DataSource and self.LinkField and self.Parent:
if self.Parent.RowCount == 0:
# Parent is new and not yet saved, so we cannot
have child records yet.
- self.setWhereClause("")
- filtExpr = " 1 = 0 "
+
self._CurrentCursor.setNonMatchChildFilterClause()
else:
val = self.escQuote(self.getParentLinkValue())
linkFieldParts = self.LinkField.split(".")
if len(linkFieldParts) < 2:
- dataSource = self.DataSource
linkField = self.LinkField
else:
# The source table was specified in the
LinkField
- dataSource = linkFieldParts[0]
linkField = linkFieldParts[1]
- filtExpr = " %s.%s = %s " % (dataSource,
linkField, val)
- self._CurrentCursor.setChildFilterClause(filtExpr)
- self.setWhereClause(currWhere)
+ self._CurrentCursor.setChildFilter(linkField,
val)
def getParentLinkValue(self):
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2009-04-15 11:03:10 UTC (rev 5179)
+++ trunk/dabo/db/dCursorMixin.py 2009-04-18 13:55:13 UTC (rev 5180)
@@ -2144,6 +2144,21 @@
autoQuote=self.AutoQuoteNames)
+ def setChildFilter(self, fld, val):
+ """ This method sets the appropriate filter for dependent child
queries."""
+ # The alias is the last 'word' in the FROM clause
+ alias = self.sqlManager._fromClause.split()[-1]
+ filtExpr = " %s.%s = %s " % (alias, fld, val)
+ self.setChildFilterClause(filtExpr)
+
+
+ def setNonMatchChildFilterClause(self):
+ """ Called when the parent has no records, which implies that
the child
+ cannot have any, either.
+ """
+ self.setChildFilterClause(" 1 = 0 ")
+
+
def getChildFilterClause(self):
""" Get the child filter part of the sql statement."""
return self.sqlManager._childFilterClause
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]