#681 closed defect (fixed)
get_in_bulk fails for PK columns other than "id"
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Given:
class MwUser(meta.Model): user_id = meta.IntegerField(primary_key=True)
This fails:
from django.models.wps import mwusers mwusers.get_in_bulk(['Wpsadmin'])
with:
Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/site-packages/django/utils/functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/usr/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1364, in function_get_in_bulk obj_list = function_get_list(opts, klass, **kwargs) File "/usr/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1135, in function_get_list return list(function_get_iterator(opts, klass, **kwargs)) File "/usr/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1118, in function_get_iterator cursor.execute("SELECT " + (kwargs.get('distinct') and "DISTINCT " or "") + ",".join(select) + sql, params) File "/usr/lib/python2.4/site-packages/django/core/db/base.py", line 10, in execute result = self.cursor.execute(sql, params) File "/usr/lib/python2.4/site-packages/django/core/db/backends/mysql.py", line 32, in execute return self.cursor.execute(sql, params) File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line 95, in execute return self._execute(query, args) File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line 114, in _execute self.errorhandler(self, exc, value) File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 33, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.OperationalError: (1054, "Unknown column 'mw_user.id' in 'where clause'")
Change History (3)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
OK, sorry; PK is integer, example should have been given: