Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13069 closed (invalid)

Update on Primary Key performs Insert

Reported by: j.dobos@… Owned by: nobody
Component: Uncategorized Version: 1.1
Severity: Keywords: Primary Key, Update, Insert
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When having a simple table with one column that is set to primary_key=True, changing its value in admin pages executes an insert instead of an update. According to the documentation: http://docs.djangoproject.com/en/dev/ref/models/instances/#how-django-knows-to-update-vs-insert I believe this behaviour is wrong.

Reproduction Steps:
1) Create simple model with one column primary_key=True (tested on charfield)
2) Insert value in the admin page
3) Attempt to change the value

Expected Result:

  • New value replaces the old one

Actual Result:

  • New row is added, the old value stays in the DB too

Attachments (0)

Change History (2)

comment:1 follow-up: Changed 4 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 behaving as designed.

comment:2 in reply to: ↑ 1 Changed 4 years ago by anonymous

Replying to russellm:

This is behaving as designed.

If this is the case, I do question such design. Primary Key should be usable as a holder of values, not only as an ID column for row of values (I can sense the same idea being enforced as in auto_id column...).

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.