Ticket #11181: faster-inserts-by-caching-manager.patch
File faster-inserts-by-caching-manager.patch, 1.2 KB (added by , 15 years ago) |
---|
-
django/db/models/base.py
455 455 pk_set = pk_val is not None 456 456 record_exists = True 457 457 manager = cls._base_manager 458 if hasattr(cls, '_insert_manager'): 459 insert_manager = cls._insert_manager 460 else: 461 insert_manager = cls._insert_manager = cls._default_manager.extra(select={'a': 1}).values('a').order_by() 462 458 463 if pk_set: 459 464 # Determine whether a record with the primary key already exists. 460 465 if (force_update or (not force_insert and 461 manager.filter(pk=pk_val).extra(select={'a': 1}).values('a').order_by())):466 insert_manager.filter(pk=pk_val).extra(select={'a': 1}).values('a').order_by())): 462 467 # It does already exist, so do an UPDATE. 463 468 if force_update or non_pks: 464 469 values = [(f, None, (raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks]