Opened 18 years ago

Closed 18 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 Holovaty
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: no UI/UX: no

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.

Change History (1)

comment:1 by Russell Keith-Magee, 18 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #2473.

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