Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#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:

  1. Create a simple model named say TestModel with a field.
  2. Populate it with some data.
  3. Create initial migration.
  4. fake your initial
  5. Add a new field
  6. Create migration or not, but in either case do not run it to alter the table
  7. 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)

debug-page.txt (4.0 KB ) - added by Frank Wiles 13 years ago.
Debug page

Download all attachments as: .zip

Change History (3)

by Frank Wiles, 13 years ago

Attachment: debug-page.txt added

Debug page

comment:1 by Alex Gaynor, 13 years ago

Resolution: needsinfo
Status: newclosed

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 Frank Wiles, 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!

Note: See TracTickets for help on using tickets.
Back to Top