Ticket #1311: dCursorMixin.patch
| File dCursorMixin.patch, 2.3 kB (added by JacekK, 2 years ago) |
|---|
-
dCursorMixin.py
old new 986 986 elif isinstance(val, dNoEscQuoteStr): 987 987 # Sometimes you want to set it to a sql function, equation, ect. 988 988 ignore = True 989 elif (fldType is str) and (type(val) is buffer): 990 # fix problem with blob fields 991 ignore = True 989 992 elif fld in nonUpdateFields: 990 993 # don't worry so much if this is just a calculated field. 991 994 ignore = True … … 1004 1007 old_val = rec[fld] 1005 1008 if old_val != val: 1006 1009 if valid_pk: 1007 if fld == keyField:1010 if (fld == keyField) or (self._compoundKey and fld in keyField): 1008 1011 # Changing the key field value, need to key the mementos on the new 1009 1012 # value, not the old. Additionally, need to copy the mementos from the 1010 1013 # old key value to the new one. 1011 keyFieldValue = val 1012 old_mem = self._mementos.get(old_val, None) 1014 if self._compoundKey: 1015 old_key = tuple([rec[k] for k in keyField]) 1016 keyFieldValue = tuple([(val if k == fld else rec[k]) 1017 for k in keyField]) 1018 else: 1019 old_key = old_val 1020 keyFieldValue = val 1021 old_mem = self._mementos.get(old_key, None) 1013 1022 if old_mem is not None: 1014 1023 self._mementos[keyFieldValue] = old_mem 1015 del self._mementos[old_val] 1016 elif self._compoundKey and fld in keyField: 1017 # Changing the value of one key field, need to key the mementos on 1018 # the new compound key value not the old. Additionally, need 1019 #to copy the mementos from the old key value to the new one. 1020 oldKeyFieldValue = tuple([rec[k] for k in keyField]) 1021 old_mem = self._mementos.get(oldKeyFieldValue, None) 1022 keyFieldValue = list(oldKeyFieldValue) 1023 keyFieldValue[list(keyField).index(fld)] = val 1024 keyFieldValue = tuple(keyFieldValue) 1025 if old_mem is not None: 1026 self._mementos[keyFieldValue] = old_mem 1027 del self._mementos[oldKeyFieldValue] 1024 del self._mementos[old_key] 1025 if old_key in self._newRecords: 1026 self._newRecords[keyFieldValue] = self._newRecords[old_key] 1027 del self._newRecords[old_key] 1028 # Should't ever happen, but just in case of desynchronization. 1029 if kons.CURSOR_TMPKEY_FIELD in rec: 1030 rec[kons.CURSOR_TMPKEY_FIELD] = keyFieldValue 1028 1031 else: 1029 1032 if self._compoundKey: 1030 1033 keyFieldValue = tuple([rec[k] for k in keyField]) 1031 1034
