[magic-removal][patch] `save` method of `AutomaticManipulator` broken for `ManyToManyField`s
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In models/manipulator.py's save() function, there is a bug that using the old-style manipulator method set_XXX, so as saving manytomany field, just like save group object in Admin, it'll be failed. So I made this patch.
And I also found that in fields/related.py,
rowcount = cursor.execute("SELECT %s FROM %s WHERE %s = %%s AND %s IN (%s)" % \
(rel_col_name, join_table, this_col_name,
rel_col_name, ",".join(%s? * len(new_ids))),
[this_pk_val] + list(new_ids))
existing_ids = set([row for row in cursor.fetchmany(rowcount)])
if there is no records after executing the SELECT, the rowcount will be None, so cursor.fetchmany(rowcount) will be failed. The patch also including fix this.
Change History (9)
comment:3 Changed 11 years ago by
|Summary:||[Patch]Fixed models/manipulator.py 'set_%s' bug → [magic-removal][patch] `save` method of `AutomaticManipulator` broken for `ManyToManyField`s|