Code

Opened 8 years ago

Closed 8 years ago

#2667 closed defect (duplicate)

calling Add on a ManyToMany field with empty arguments results in bad SQL

Reported by: carl.shimer@… Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Scenario:

You have generic code which wants to add one or more entries to a ManyToMany field. the easy way to do this is something like this:

mapping_values = Model_one.object.all.filter(foo__bar__baz__in=mylistcriteria)
exising_object.manytomanyfield.add(*mapping_values)

if mapping fields is empty,e.g [] this will result in an exception because of bogus SQL generation.
calling add with empty args should probably do nothing rather than throwing an exception. Of course,this is easy to code around with a simplecheck.

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by russellm

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

Duplicate of #2473.

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.