Code

Opened 7 years ago

Closed 7 years ago

#3484 closed (duplicate)

Poor error message (or functionality) when using unsaved models as foreign keys

Reported by: Dave Abrahams <dave@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This reduced case untested, sorry.

from django.db import models

class X(models.Model):
    pass

class Y(models.Model):
    x = models.ForeignKey(X)

x = X()
Y(x=x).save()

The result,
IntegrityError: ERROR: null value in column "presenter_id" violates not-null constraint, is cryptic at best. Maybe rather than improving the error message, it should recursively save all unsaved models?

Attachments (0)

Change History (4)

comment:1 Changed 7 years ago by Dave Abrahams <dave@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Oops, not presenter_id, but x_id

comment:2 Changed 7 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Design decision needed

I think just improving the error message would be enough. But what does core think?

comment:3 Changed 7 years ago by SmileyChris

  • Summary changed from Poor error message (or functionality) to Poor error message (or functionality) when using unsaved models as foreign keys

comment:4 Changed 7 years ago by ubernostrum

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #3016, I believe; fixing that should fix this.

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.