Opened 18 years ago

Closed 18 years ago

#2894 closed defect (fixed)

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

Reported by: andrew@… Owned by: Adrian Holovaty
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: no UI/UX: no

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@… 18 years ago.
Simple patch to handle None case.

Download all attachments as: .zip

Change History (3)

by andrew@…, 18 years ago

Attachment: deserialize_none_fk.diff added

Simple patch to handle None case.

comment:1 by andrew@…, 18 years ago

Summary: XML Deserializer does not handle None values in Foreign Keys[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 by Jacob, 18 years ago

Resolution: fixed
Status: newclosed

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

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