the singularity of being and nothingness
ColdFusion Bug: SerializeJSON() and ORM Entities
Recently, I’ve been messing around quite a bit with ORM in ColdFusion. I really like the benefits that it brings to developing applications. However, I noticed a very big bug yesterday while attempting to user serializeJSON() on a an entity using a one-to-many relationship.
Some Context
Let’s say that you have two entities that are related via a one-to-many relationship (Artists and Art, for example). You can easily create this relationship in your model by doing something like the following:
property name="art" fieldtype="one-to-many" fkcolumn="artistid" cfc="Art" remotingfetch="true";
If we were to dump the result of an EntityLoad() of “Artists”, we’d see a nice structured relationship: First, an array of all Artist entities, and then an array of all Art entities related to the particular ArtistID. Additionally, I’ve specified remotingfetch=true, which will force CF to load the Art entities for each Artist.
The Bug
The bug, however, comes into play when you try to serialize the result of EntityLoad(). While it properly composes the relationships, it represents the first two entities in the “art” array; any subsequent entities in the given array are returned simply as “{}”. Whether you have 3 “Art” entities for an artists, or 20, only the first 2 will ever be serialized properly.
See this happening in CF10:
It Gets Worse
The worst part about this is that it is a relatively old bug. It was first submitted for CF9 back in October 2010, was deferred, and was apparently not fixed for the public beta of CF10.
I think this is a huge issue, and should be a priority to be fixed. Until it is (or a suitable workaround is devised), it will be incredibly difficult to create applications of any complexity that depend upon serialization of entities.
Vote, Vote, Vote
The best way to get it fixed, of course, is to make your voice heard and vote up the bug. Here are some links for that:
Bug Report – CF 9: https://bugbase.adobe.com/index.cfm?event=bug&id=3042650
Bug Report – CF 10: https://bugbase.adobe.com/index.cfm?event=bug&id=3175667
Print article | This entry was posted by existdissolve on April 26, 2012 at 8:13 am, and is filed under ColdFusion. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |