#16795 closed Bug (needsinfo)
ORM masks exception in Python shells
Reported by: | Frank Wiles | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.3 |
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
If you have a simple model and add a field to it, creating a South migration, but neglect to run the migration querying the model returns an empty list rather than raising an exception. Properly raises DatabaseError in a template however.
Steps to reproduce:
- Create a simple model named say TestModel with a field.
- Populate it with some data.
- Create initial migration.
- fake your initial
- Add a new field
- Create migration or not, but in either case do not run it to alter the table
- run TestModel.objects.all() in Python shell (also happens in IPython) and it returns []
When visiting a view that uses that same QuerySet it properly raises a DatabaseError (from a psycopg2 ProgrammingError), but not in the shell. I couldn't find any place in the backend where it's being caught and silently ignored. Attached template debug page.
Attachments (1)
Change History (3)
by , 13 years ago
Attachment: | debug-page.txt added |
---|
comment:1 by , 13 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Are you on Python 2.6.1? If so this is a known issue with that release, nothing we can do about it (the issue is not the shell, but rather it attempting to call list
to generate the repr).
comment:2 by , 13 years ago
Yup running 2.6.1, was surprised when I ran into it and couldn't find a bug in it. That'd be the issue then, thanks!
Debug page