dabo Commit
Revision 6862
Date: 2011-09-27 18:50:33 -0700 (Tue, 27 Sep 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6862
Changed:
U trunk/dabo/dException.py
U trunk/dabo/db/dCursorMixin.py
Log:
Fixed the issue with missing PKs when adding to many-to-many relationships
Diff:
Modified: trunk/dabo/dException.py
===================================================================
--- trunk/dabo/dException.py 2011-09-27 22:29:26 UTC (rev 6861)
+++ trunk/dabo/dException.py 2011-09-28 01:50:33 UTC (rev 6862)
@@ -28,12 +28,19 @@
class BusinessRuleViolation(dException):
pass
+
class BusinessRulePassed(dException):
pass
+
class RowNotFoundException(dException):
pass
+
+class DataSourceNotFoundException(dException):
+ pass
+
+
class FeatureNotImplementedException(dException):
pass
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2011-09-27 22:29:26 UTC (rev 6861)
+++ trunk/dabo/db/dCursorMixin.py 2011-09-28 01:50:33 UTC (rev 6862)
@@ -1129,7 +1129,7 @@
return True
- def lookupPKWithAdd(self, field, val, tbl=None):
+ def lookupPKWithAdd(self, field, val, tbl=None, pkCol=None):
"""Runs a lookup in the specified field for the desired value.
If
found, returns the PK for that record. If not found, a record is
inserted into the table, with its 'field' column populated with
'val',
@@ -1138,8 +1138,10 @@
aux = self.AuxCursor
if tbl is None:
tbl = self.Table
+ if pkCol is None:
+ pkCol = self.KeyField
sql = self._qMarkToParamPlaceholder("select %s from %s where %s
= ?"
- % (self.KeyField, tbl, field))
+ % (pkCol, tbl, field))
try:
dabo.dbActivityLog.info("lookupPKWithAdd() SQL: %s,
PARAMS: %s" % (
sql.decode(self.Encoding).replace("\n",
" "), "(%s, )" % val))
@@ -1194,7 +1196,7 @@
otherTable = self._mmOtherTable
thisPK = self.getPK()
for otherVal in listOfValues:
- otherPK = self.lookupPKWithAdd(otherField, otherVal,
otherTable)
+ otherPK = self.lookupPKWithAdd(otherField, otherVal,
otherTable, self._mmOtherPKCol)
aux = self.AuxCursor
sql = self._qMarkToParamPlaceholder("delete from %s
where %s = ? and %s = ?"
% (self._assocTable,
self._assocPKColThis, self._assocPKColOther))
@@ -1252,7 +1254,7 @@
thisTable = self.Table
otherTable = self._mmOtherTable
thisPK = self.lookupPKWithAdd(thisField, thisVal, thisTable)
- otherPK = self.lookupPKWithAdd(otherField, otherVal, otherTable)
+ otherPK = self.lookupPKWithAdd(otherField, otherVal,
otherTable, self._mmOtherPKCol)
aux = self.AuxCursor
sql = self._qMarkToParamPlaceholder("select * from %s where %s
= ? and %s = ?"
% (self._assocTable, self._assocPKColThis,
self._assocPKColOther))
_______________________________________________
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]