Opened 8 years ago

Closed 8 years ago

#2894 closed defect (fixed)

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

Reported by: andrew@… Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 (1)

deserialize_none_fk.diff (909 bytes) - added by andrew@… 8 years ago.
Simple patch to handle None case.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by andrew@…

Simple patch to handle None case.

comment:1 Changed 8 years ago by andrew@…

  • 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.

comment:2 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

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

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