Opened 8 years ago

Closed 8 years ago

#6563 closed (duplicate)

field=None in get_or_create

Reported by: dcramer Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


There is a problem when using get_or_create in the following situation:

MyModel.objects.get_or_create(field=None, field1=Hi, defaults=dict(x=1, y=2))

One would expect this to insert field as None, if one doesnt match where field is NULL (how else would propose to approach that?)

The problem is it treats the insert as NULL, but not the select.

This goes along the same lines in Django where None != NULL, which I believe it should.

Change History (2)

comment:1 Changed 8 years ago by ubernostrum

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

MyModel.objects.get_or_create(field__isnull=True, field1=Hi, defaults=dict(x=1, y=2))

comment:2 Changed 8 years ago by mtredinnick

  • Resolution set to duplicate
  • Status changed from new to closed
  • Summary changed from [bug] field=None in get_or_create to field=None in get_or_create

I'm going to mark this as a dupe of #2737, since it looks like just a consequence of the select behaviour, as you note. That behaviour's been changed in queyrset-refactor.

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