Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16795 closed Bug (needsinfo)

ORM masks exception in Python shells

Reported by: frankwiles 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 frankwiles 3 years ago.
Debug page

Download all attachments as: .zip

Change History (3)

Changed 3 years ago by frankwiles

Debug page

comment:1 Changed 3 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to 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 Changed 3 years ago by frankwiles

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!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.