Opened 12 years ago

Closed 12 years ago

#18284 closed Bug (invalid)

"has_bulk_insert = False" results in only saving one ManyToManyField

Reported by: Michael Manfre Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Release blocker Keywords: regression, bulk_insert
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Attempts to save multiple values for a ManyToManyField will only save one. It appears to follow the same pattern for bulk insert; delete all for parent record followed by a single insert. The form collects and passing down the appropriate clean_data, but only the first value is inserted in to the database.

This is a regression that will cause data errors for 3rd party db backends that have not (or cannot) enable the has_bulk_insert = True database feature. The core backends are unaffected because they have enabled the feature.

Discovered issue by using django-mssql. It'll no longer an issue as of django-mssql>=1.1a2. Version 1.1a1 added django 1.4 support, so no one should be using it on production yet. It's possible this regression only impacts django-mssql, but the SQLInsertCompiler is mostly a pass through to core.

A quick source check for django-pyodbc and ibm_db_django show that they have not enabled the feature.

Change History (2)

comment:1 by Michael Manfre, 12 years ago

Opened tickets for django-pyodbc (https://code.google.com/p/django-pyodbc/issues/detail?id=124) and ibm-db-django (https://code.google.com/p/ibm-db/issues/detail?id=109&thanks=109&ts=1336415266) to give them heads up about this potential data loss issue.

comment:2 by Anssi Kääriäinen, 12 years ago

Resolution: invalid
Status: newclosed

It seems the bug is in django-mssql. It seems django-mssql v1.1a1 only returned one insert statement per call to InsertCompiler.as_sql().

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