Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13228 closed (duplicate)

queryset.update() on custom manager ignores all filter

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

Description

model:

class Party(models.Model):
    name = models.CharField(max_length=50)
    is_company = models.BooleanField()

class CompanyManager(models.Manager):

    def get_query_set(self):
        return super(CompanyManager, self).get_query_set().filter(is_company=True)

class Company(Party):
    objects = CompanyManager()
    class Meta:
        proxy = True

show bug:

>>> Company.objects.create(name='GlideTools')
>>> Company.objects.filter(name='M$')
[]
>>> Company.objects.filter(name='M$').update(name='What?!')
1
>>> [p.name for p in Party.objects.all()]
[u'What?!']

The update() updates all objects, All filters on it is ignored!

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by kmtracey

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

This is a dupe of #12247.

comment:2 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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.