Ticket #1311: dCursorMixin.2.patch

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

    old new  
    976976                elif isinstance(val, dNoEscQuoteStr): 
    977977                    # Sometimes you want to set it to a sql function, equation, ect. 
    978978                    ignore = True 
     979                elif (fldType is str) and (type(val) is buffer): 
     980                    # fix problem with blob fields 
     981                    ignore = True 
    979982                elif fld in nonUpdateFields: 
    980983                    # don't worry so much if this is just a calculated field. 
    981984                    ignore = True 
     
    994997        old_val = rec[fld] 
    995998        if old_val != val: 
    996999            if valid_pk: 
    997                 if fld == keyField
     1000                if (fld == keyField) or (self._compoundKey and fld in keyField)
    9981001                    # Changing the key field value, need to key the mementos on the new 
    9991002                    # value, not the old. Additionally, need to copy the mementos from the 
    10001003                    # 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) 
    10031012                    if old_mem is not None: 
    10041013                        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 
    10061021                else: 
    10071022                    if self._compoundKey: 
    10081023                        keyFieldValue = tuple([rec[k] for k in keyField]) 
    10091024                    else: 
    10101025                        keyFieldValue = rec[keyField] 
    10111026                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): 
    10131029                    # Memento is already there, or it isn't updateable. 
    10141030                    pass 
    10151031                else: 
     
    14491465        """Erase the memento for the passed row, or current row if none passed.""" 
    14501466        if row is None: 
    14511467            row = self.RowNumber 
    1452         rec = self._records[row] 
    14531468 
    14541469        try: 
    14551470            pk = self.getPK(row)