Ticket #1311: dCursorMixin.patch

File dCursorMixin.patch, 2.3 kB (added by JacekK, 2 years ago)
  • dCursorMixin.py

    old new  
    986986                elif isinstance(val, dNoEscQuoteStr): 
    987987                    # Sometimes you want to set it to a sql function, equation, ect. 
    988988                    ignore = True 
     989                elif (fldType is str) and (type(val) is buffer): 
     990                    # fix problem with blob fields 
     991                    ignore = True 
    989992                elif fld in nonUpdateFields: 
    990993                    # don't worry so much if this is just a calculated field. 
    991994                    ignore = True 
     
    10041007        old_val = rec[fld] 
    10051008        if old_val != val: 
    10061009            if valid_pk: 
    1007                 if fld == keyField
     1010                if (fld == keyField) or (self._compoundKey and fld in keyField)
    10081011                    # Changing the key field value, need to key the mementos on the new 
    10091012                    # value, not the old. Additionally, need to copy the mementos from the 
    10101013                    # 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) 
    10131022                    if old_mem is not None: 
    10141023                        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 
    10281031                else: 
    10291032                    if self._compoundKey: 
    10301033                        keyFieldValue = tuple([rec[k] for k in keyField]) 
    10311034