Ticket #1311: dCursorMixin.2.patch
| File dCursorMixin.2.patch, 2.3 kB (added by JacekK, 2 years ago) |
|---|
-
dabo/db/dCursorMixin.py
old new 976 976 elif isinstance(val, dNoEscQuoteStr): 977 977 # Sometimes you want to set it to a sql function, equation, ect. 978 978 ignore = True 979 elif (fldType is str) and (type(val) is buffer): 980 # fix problem with blob fields 981 ignore = True 979 982 elif fld in nonUpdateFields: 980 983 # don't worry so much if this is just a calculated field. 981 984 ignore = True … … 994 997 old_val = rec[fld] 995 998 if old_val != val: 996 999 if valid_pk: 997 if fld == keyField:1000 if (fld == keyField) or (self._compoundKey and fld in keyField): 998 1001 # Changing the key field value, need to key the mementos on the new 999 1002 # value, not the old. Additionally, need to copy the mementos from the 1000 1003 # old key value to the new one. 1001 keyFieldValue = val 1002 old_mem = self._mementos.get(old_val, None) 1004 if self._compoundKey: 1005 old_key = tuple([rec[k] for k in keyField]) 1006 keyFieldValue = tuple([(val if k == fld else rec[k]) 1007 for k in keyField]) 1008 else: 1009 old_key = old_val 1010 keyFieldValue = val 1011 old_mem = self._mementos.get(old_key, None) 1003 1012 if old_mem is not None: 1004 1013 self._mementos[keyFieldValue] = old_mem 1005 del self._mementos[old_val] 1014 del self._mementos[old_key] 1015 if old_key in self._newRecords: 1016 self._newRecords[keyFieldValue] = self._newRecords[old_key] 1017 del self._newRecords[old_key] 1018 # Should't ever happen, but just in case of desynchronization. 1019 if kons.CURSOR_TMPKEY_FIELD in rec: 1020 rec[kons.CURSOR_TMPKEY_FIELD] = keyFieldValue 1006 1021 else: 1007 1022 if self._compoundKey: 1008 1023 keyFieldValue = tuple([rec[k] for k in keyField]) 1009 1024 else: 1010 1025 keyFieldValue = rec[keyField] 1011 1026 mem = self._mementos.get(keyFieldValue, {}) 1012 if (fld in mem) or (fld in nonUpdateFields): 1027 if (fld in mem) or (fld in self.nonUpdateFields): 1028 # Temporary fix: #or (fld in nonUpdateFields): 1013 1029 # Memento is already there, or it isn't updateable. 1014 1030 pass 1015 1031 else: … … 1449 1465 """Erase the memento for the passed row, or current row if none passed.""" 1450 1466 if row is None: 1451 1467 row = self.RowNumber 1452 rec = self._records[row]1453 1468 1454 1469 try: 1455 1470 pk = self.getPK(row)
