#11764 closed (fixed)
Bugfix: typo with avoid.update(..) in db/models/sql/compiler.py:SQLCompiler:fill_related_selections
| Reported by: | Aurelio Tinio | Owned by: | Ramiro Morales |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | django@… | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
There looks to be a bug due to a typo in db/models/sql/query.py .
The issue became apparent when it prevented the display of a ForeignKey field in list_display, when there is another ForeignKey to the base class of the model with the following error displayed:
Caught an exception while rendering: update() takes exactly one argument (2 given)
Original Traceback (most recent call last):
File "/tippit/django-projects/django/Django-1.1/django/template/debug.py", line 71, in render_node
result = node.render(context)
File "/tippit/django-projects/django/Django-1.1/django/template/__init__.py", line 936, in render
dict = func(*args)
File "/tippit/django-projects/django/Django-1.1/django/contrib/admin/templatetags/admin_list.py", line 253, in result_list
'results': list(results(cl))}
File "/tippit/django-projects/django/Django-1.1/django/contrib/admin/templatetags/admin_list.py", line 247, in results
for res in cl.result_list:
File "/tippit/django-projects/django/Django-1.1/django/db/models/query.py", line 106, in _result_iter
self._fill_cache()
File "/tippit/django-projects/django/Django-1.1/django/db/models/query.py", line 692, in _fill_cache
self._result_cache.append(self._iter.next())
File "/tippit/django-projects/django/Django-1.1/django/db/models/query.py", line 238, in iterator
for row in self.query.results_iter():
File "/tippit/django-projects/django/Django-1.1/django/db/models/sql/query.py", line 287, in results_iter
for rows in self.execute_sql(MULTI):
File "/tippit/django-projects/django/Django-1.1/django/db/models/sql/query.py", line 2360, in execute_sql
sql, params = self.as_sql()
File "/tippit/django-projects/django/Django-1.1/django/db/models/sql/query.py", line 395, in as_sql
self.pre_sql_setup()
File "/tippit/django-projects/django/Django-1.1/django/db/models/sql/query.py", line 589, in pre_sql_setup
self.fill_related_selections()
File "/tippit/django-projects/django/Django-1.1/django/db/models/sql/query.py", line 1401, in fill_related_selections
())
TypeError: update() takes exactly one argument (2 given)
A patch has been attached applied against changeset 11475.
Attachments (4)
Change History (13)
by , 16 years ago
| Attachment: | patch_against_11475.diff added |
|---|
by , 16 years ago
| Attachment: | 11764.diff added |
|---|
comment:1 by , 16 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
Finally got around to reproduce this corner case thing by tracing and copying the treatment the queryset gets in the admin app to show a change list for the relevant model (there is no need to create model instances at all). Critical to make the bug show itself are the select_related() call and iterating over the QS (forcing its evaluation with list() doesn't trigger it).
comment:2 by , 16 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
follow-up: 4 comment:3 by , 16 years ago
| Cc: | added |
|---|---|
| Summary: | Bugfix: typo with avoid.update(..) in db/models/sql/query.py:BaseQuery:fill_related_selections → Bugfix: typo with avoid.update(..) in db/models/sql/compiler.py:SQLCompiler:fill_related_selections |
Updated patch as the typo had moved from [source:django/trunk/django/db/models/sql/query.py query.py] to [source:django/trunk/django/db/models/sql/compiler.py compiler.py].
comment:4 by , 16 years ago
Replying to wogan:
Updated patch as the typo had moved from [source:django/trunk/django/db/models/sql/query.py query.py] to [source:django/trunk/django/db/models/sql/compiler.py compiler.py].
Thanks for updating the patch. I had spotted the code move and implemented a simliar updating locally. Problem is that the regression test case I had added now pass with and without the fix applied. I ran the full Django test suite with code coverage analysis turned on and it shows that exact code path isn't exercised anymore.
This means we need to update the test because the core committers won't get this change in without a regression test. But I don't know if it's possible at all.
Sorry for not updating the ticket, I only made a comment about this on the #django-dev IRC channel.
comment:5 by , 16 years ago
| Triage Stage: | Ready for checkin → Accepted |
|---|
Moving off of RFC since ramiro notes that we can longer reproduce this :/
comment:7 by , 16 years ago
| milestone: | 1.3 → 1.2 |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Updated the patch, made a minor change to the test.
I could successfully run the test (failing appropriately when the patch is not applied).
Is it possible to get this in for 1.2?
comment:8 by , 16 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Same code patch plus regression test