close Warning: HTML preview using PatchRenderer failed (UndefinedError: list object has no element 0)

Ticket #1519: extra-select-dict.diff

File extra-select-dict.diff, 1.0 KB (added by Antti Kaihola, 19 years ago)

fix extra(select=) to accept a dict

Line 
1Index: django/db/models/query.py
2===================================================================
3--- django/db/models/query.py (revision 2529)
4+++ django/db/models/query.py (working copy)
5@@ -314,7 +314,7 @@
6 assert self._limit is None and self._offset is None, \
7 "Cannot change a query once a slice has been taken"
8 clone = self._clone()
9- if select: clone._select.extend(select)
10+ if select: clone._select.update(select)
11 if where: clone._where.extend(where)
12 if params: clone._params.extend(params)
13 if tables: clone._tables.extend(tables)
14@@ -386,0 +386,0 @@
15
16 # Add any additional SELECTs.
17 if self._select:
18- select.extend(['(%s) AS %s' % (quote_only_if_word(s[1]), backend.quote_name(s[0])) for s in self._select])
19+ select.extend(['(%s) AS %s' % (quote_only_if_word(s[1]), backend.quote_name(s[0])) for s in self._select.items()])
20
21 # Start composing the body of the SQL statement.
22 sql = [" FROM", backend.quote_name(opts.db_table)]
Back to Top