Opened 7 years ago

Closed 13 months ago

#11523 closed Bug (wontfix)

ORM/MySQL backend doesn't set pk when Warning exception is raised

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


Link to the discussion:


from MySQLdb import Warning as Warning
from django.db import models
import unittest

class TestModel(models.Model):
    char_field = models.CharField(max_length=5)

class Case1(unittest.TestCase):
    def test1(self):
        print "Count 1:", TestModel.objects.count()
        m = TestModel(char_field="123456")
        except Warning:
            print "Count 2:", TestModel.objects.count()
            print "",
            print "all()[0].id=", TestModel.objects.all()[0].id

The above code prints:

Count 1: 0
Count 2: 1 None
all()[0].id= 1 
  • which means to me that although m is saved to db, primary key is not set in after

If you look into newsgroups thread above, it seems that MySQLdb returns pk properly.

Change History (5)

comment:1 Changed 7 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:3 Changed 5 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:4 Changed 5 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:5 Changed 13 months ago by timgraham

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

As of #23871, Django no longer promotes warnings to exceptions, so I think this issue is obsolete.

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