#3390: Deserializer cannot handle circular and forward references to object
instances
--------------------------------------------------------------------------+-
Reporter: russellm |
Owner: jacob
Status: new |
Component: Serialization
Version: SVN |
Resolution:
Keywords: JSON deferrable deserialization circular forward reference |
Stage: Design decision needed
Has_patch: 1 |
Needs_docs: 0
Needs_tests: 0 |
Needs_better_patch: 1
--------------------------------------------------------------------------+-
Comment (by russellm):
Replying to [comment:4 mtredinnick]:
> I don't like this solution. Until now, the serializer provided a nice
way to move data between Django installations: I could email somebody the
serialised output and they could run it as an addition to their database.
Or I could save it away and use it later after arbitrary things have
happened in my database. But you can't do that if you also want to control
the primary key values, because it may clash with existing ones.
I'm not sure the existing serializer works in the way you suggest. In the
existing implementation (of JSON, at least):
- A serialization file contains the primary key for each object
serialized; when each object is saved, it will overwrite any object in the
database with that primary key.
- If a serialized object contains a reference (FK or m2m) to an object,
the deserializer looks in the database for an existing object with that
primary key. If an object with that primary key already exists in the
database, or has previously been deserialized, the reference is set; if it
doesn't, an integrity error is thrown (hence this bug report).
Neither of these properties allow you to arbitrarily add blocks of data to
the database. Primary keys have always been controlled by the serializer,
and existing database objects have always been overwritten by deserialized
ones.
I suppose you could add an 'overwrite' flag to the deserializer to
differentiate between 'create a new object' and 'overwrite existing
objects' when an object is deserialized - but then it would be difficult
to keep references consistent. When my serialized object references PK=3,
does it mean the PK=3 object in my file, or the PK=3 object in the
database into which it is being loaded?
--
Ticket URL: <http://code.djangoproject.com/ticket/3390#comment:5>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---