I have two models with OneToOne relation
class Unit (models.Model):
label = models.CharField(max_length=32)
datastream = models.OneToOneField ('Datastream', null=True, blank=True,
related_name="unit")
...
class Datastream (models.Model):
idd = models.AutoField(primary_key=True, auto_created=True, null=True)
id = models.CharField(max_length=32)
...
During deletion of datastream these commands executed on DB server:
SQL: UPDATE "feeds_unit" SET "datastream_id" = NULL WHERE "id" IN (?, ?, ?)
PARAMS: (4, 5, 6)
SQL: DELETE FROM "feeds_unit" WHERE "id" IN (?, ?, ?)
PARAMS: (6, 5, 4)
I tried sqlite3 as backend - works fine.
But MSSQL raise error on "UPDATE "feeds_unit" SET "datastream_id" = NULL
WHERE "id" IN (?, ?, ?)"
Error:
IntegrityError: ('23000', "[23000] [Microsoft][ODBC SQL Server Driver][SQL
Server]Violation of UNIQU
E KEY constraint 'UQ__feeds_un__EAC1B8893E847883'. Cannot insert duplicate
key in object 'dbo.feeds_
unit'. The duplicate key value is (<NULL>). (2627) (SQLExecDirectW);
[01000] [Microsoft][ODBC SQL Se
rver Driver][SQL Server]The statement has been terminated. (3621)")
Can anybody help me?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.