Django

Code

Show
Ignore:
Timestamp:
06/25/07 07:47:19 (2 years ago)
Author:
mtredinnick
Message:

unicode: Merged from trunk up to [5530]. Oracle backend has not been ported to
support unicode yet.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode

    • Property svnmerge-integrated changed from /django/trunk:1-5460 to /django/trunk:1-5530
  • django/branches/unicode/django/db/models/base.py

    r5400 r5531  
    100100    def __init__(self, *args, **kwargs): 
    101101        dispatcher.send(signal=signals.pre_init, sender=self.__class__, args=args, kwargs=kwargs) 
    102          
     102 
    103103        # There is a rather weird disparity here; if kwargs, it's set, then args 
    104         # overrides it. It should be one or the other; don't duplicate the work  
     104        # overrides it. It should be one or the other; don't duplicate the work 
    105105        # The reason for the kwargs check is that standard iterator passes in by 
    106106        # args, and nstantiation for iteration is 33% faster. 
     
    126126                if isinstance(field.rel, ManyToOneRel): 
    127127                    kwargs.pop(field.attname, None) 
    128          
     128 
    129129        # Now we're left with the unprocessed fields that *must* come from 
    130130        # keywords, or default. 
    131          
     131 
    132132        for field in fields_iter: 
    133133            if kwargs: 
     
    151151                                val = getattr(rel_obj, field.rel.get_related_field().attname) 
    152152                            except AttributeError: 
    153                                 raise TypeError("Invalid value: %r should be a %s instance, not a %s" %  
     153                                raise TypeError("Invalid value: %r should be a %s instance, not a %s" % 
    154154                                    (field.name, field.rel.to, type(rel_obj))) 
    155155                else: 
     
    214214        if pk_set: 
    215215            # Determine whether a record with the primary key already exists. 
    216             cursor.execute("SELECT 1 FROM %s WHERE %s=%%s LIMIT 1" % \ 
    217                 (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)), [pk_val]) 
     216            cursor.execute("SELECT COUNT(*) FROM %s WHERE %s=%%s" % \ 
     217                (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)), 
     218                self._meta.pk.get_db_prep_lookup('exact', pk_val)) 
    218219            # If it does already exist, do an UPDATE. 
    219             if cursor.fetchone()
     220            if cursor.fetchone()[0] > 0
    220221                db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f in non_pks] 
    221222                if db_values: 
     
    224225                        ','.join(['%s=%%s' % backend.quote_name(f.column) for f in non_pks]), 
    225226                        backend.quote_name(self._meta.pk.column)), 
    226                         db_values + [pk_val]
     227                        db_values + self._meta.pk.get_db_prep_lookup('exact', pk_val)
    227228            else: 
    228229                record_exists = False