Ticket #2705: for_update_7477.patch
File for_update_7477.patch, 4.1 KB (added by , 17 years ago) |
---|
-
django/db/models/sql/query.py
67 67 self.order_by = [] 68 68 self.low_mark, self.high_mark = 0, None # Used for offset/limit 69 69 self.distinct = False 70 self.select_for_update = False 70 71 self.select_related = False 71 72 self.related_select_cols = [] 72 73 … … 155 156 obj.order_by = self.order_by[:] 156 157 obj.low_mark, obj.high_mark = self.low_mark, self.high_mark 157 158 obj.distinct = self.distinct 159 obj.select_for_update = self.select_for_update 158 160 obj.select_related = self.select_related 159 161 obj.related_select_cols = [] 160 162 obj.max_depth = self.max_depth … … 193 195 obj = self.clone() 194 196 obj.clear_ordering(True) 195 197 obj.clear_limits() 198 obj.select_for_update = False 196 199 obj.select_related = False 197 200 obj.related_select_cols = [] 198 201 obj.related_select_fields = [] … … 272 275 result.append('LIMIT %d' % val) 273 276 result.append('OFFSET %d' % self.low_mark) 274 277 278 if self.select_for_update: 279 result.append("%s" % self.connection.ops.for_update_sql()) 280 275 281 params.extend(self.extra_params) 276 282 return ' '.join(result), tuple(params) 277 283 -
django/db/models/manager.py
108 108 def order_by(self, *args, **kwargs): 109 109 return self.get_query_set().order_by(*args, **kwargs) 110 110 111 def select_for_update(self, *args, **kwargs): 112 return self.get_query_set().select_for_update(*args, **kwargs) 113 111 114 def select_related(self, *args, **kwargs): 112 115 return self.get_query_set().select_related(*args, **kwargs) 113 116 -
django/db/models/query.py
256 256 del_query = self._clone() 257 257 258 258 # Disable non-supported fields. 259 del_query.query.select_for_update = False 259 260 del_query.query.select_related = False 260 261 del_query.query.clear_ordering() 261 262 … … 390 391 else: 391 392 return self._filter_or_exclude(None, **filter_obj) 392 393 394 def select_for_update(self): 395 """ 396 Returns a new QuerySet instance that will select objects with a 397 FOR UPDATE lock. 398 """ 399 obj = self._clone() 400 obj.query.select_for_update = True 401 return obj 402 393 403 def select_related(self, *fields, **kwargs): 394 404 """ 395 405 Returns a new QuerySet instance that will select related objects. If -
django/db/backends/sqlite3/base.py
52 52 # function django_date_trunc that's registered in connect(). 53 53 return 'django_date_trunc("%s", %s)' % (lookup_type.lower(), field_name) 54 54 55 def for_update_sql(): 56 # sqlite does not support FOR UPDATE 57 return '' 58 55 59 def drop_foreignkey_sql(self): 56 60 return "" 57 61 … … 171 175 return bool(re.search(re_pattern, re_string)) 172 176 except: 173 177 return False 178 -
django/db/backends/__init__.py
159 159 """ 160 160 return cursor.lastrowid 161 161 162 def for_update_sql(self): 163 """ 164 Return FOR UPDATE SQL clause to lock row for update 165 """ 166 return 'FOR UPDATE' 167 162 168 def limit_offset_sql(self, limit, offset=None): 163 169 """ 164 170 Returns a LIMIT/OFFSET SQL clause, given a limit and optional offset.