Opened 7 years ago

Closed 7 years ago

#7578 closed (invalid)

error in any ORM operations after 'duplicate key violation'

Reported by: san@… 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:

Description

create models

class TestCommon(models.Model):
	name=models.CharField(max_length=10, unique=True)
class Test1(TestCommon):
	num1=models.IntegerField()
class Test2(TestCommon):
	num2=models.IntegerField()

then

python manage.py shell
>>> from mysite.cp.models import TestCommon, Test1, Test2
>>> Test1.objects.create(name='test2',num1=1)
<Test1: Test1 object>
-- this works good
Test1.objects.create(name='test2',num1=1)
-- this returns error 'duplicate key violation' in name field
Test1.objects.create(name='test3',num1=1)

-- now this will not work

and any other request will not work too

I have Checked out revision 7810.

DATABASE_ENGINE = 'postgresql_psycopg2'

Change History (1)

comment:1 Changed 7 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

This is a feature of the Postgres transactions; once an error is found on the cursor, you need to roll back the transaction to remove the effect of the error.

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