Django

Code

Ticket #2894 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] XML Deserializer does not handle None values in Foreign Keys

Reported by: andrew@theptrgroup.com Assigned to: adrian
Milestone: Component: Core framework
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Although the XML Serializer handle_fk_field method goes out of its way to create a 'None' element if the foreign key relation is None, the Deserializer fails to handle the case.

Example: In a Model with a self-referential Foreign key which is allowed to be blank (and null), you may have entries with a blank value. This gets mapped to the 'None' element over the wire and results in an exception when the system attempts to find the related key with primary key , since the None element contains no text.

Attachments

deserialize_none_fk.diff (0.9 kB) - added by andrew@theptrgroup.com on 10/09/06 23:07:00.
Simple patch to handle None case.

Change History

10/09/06 23:07:00 changed by andrew@theptrgroup.com

  • attachment deserialize_none_fk.diff added.

Simple patch to handle None case.

10/09/06 23:11:43 changed by andrew@theptrgroup.com

  • summary changed from XML Deserializer does not handle None values in Foreign Keys to [patch] XML Deserializer does not handle None values in Foreign Keys.

A simple patch to detect the None element. It is not exceedingly paranoid about the XML structure, but the test should be resilient to badness (crash-wise) since it only subscripts if there is exactly one child and any child/node is guaranteed to have a nodeName, even if it turns out to be an attribute or something weird.

11/06/06 23:01:35 changed by jacob

  • status changed from new to closed.
  • resolution set to fixed.

(In [4046]) Fixed #2894: XML deserializer now correctly handles null primary keys.


Add/Change #2894 ([patch] XML Deserializer does not handle None values in Foreign Keys)




Change Properties
Action