Code

Opened 3 years ago

Closed 3 years ago

#15345 closed (invalid)

Model inheritance: wrong action of child_class_instance.delete()

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

Description

#
#myapp.models
class Place(models.Model):

description = models.TextField()
def unicode(self):

return self.description

def reload(self):

self = Place.objects.get(id = self.id)

class Restaurant(Place):

name = models.TextField()

#console
from myapp.models import *
p1 = Place.object.create(description = "description1")
r1 = Restaurant.object.create(id = p1.id, description = p1.description, name =name)
r1.delete()
r1 = Restaurant.objects.get(id = r1.id)
# return expected error
p1 = Place.objects.get(id = p1.id)
# return unexpected error, possible because that row is also deleted

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by truongsinh

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by truongsinh

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

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.