|
All – I checked in an update yesterday that shouldn’t break
anything. It did fix a few bugs and added a couple small features. In particular I found that a bug fix that was submitted was,
in fact, incorrect and broke stuff. As a result I added a way to explicitly
create an object that hasMany of itself via a linking relationship. For
example, let’s say you have a user and the user is related to other users
via a relatedUser table. Previously you would have had to have defined two
configurations for the user and one for relatedUser. For example: <object name=”user”> <hasMany
name=”user2”> <link
name=”relatedUser”> </hasMany> </object> <object name=”relatedUser”> <hasOne
name=”user”> <relate
from=”userId” to=”userId” /> </hasOne> <hasOne
name=”user2”> <relate
from=”relatedUserId” to=”userId” /> </hasOne> </object> <object name=”user2”> </object> The problem is that you end up with user2 being different
for user1. This means that if you have user Mike and user Fred you can’t
simply say Mike’s related to Fred. You’d have to create a new
user2 for Fred and relate that. You couldn’t simply do this either: <object name=”user”> <hasMany
name=”user” alias=”relation”> <link
name=”relatedUser”> </hasMany> </object> <object name=”relatedUser”> <hasOne
name=”user”> <relate
from=”userId” to=”userId” /> </hasOne> <hasOne
name=”user” alias=”relatedUser”> <relate
from=”relatedUserId” to=”userId” /> </hasOne> </object> The problem is that Reactor didn’t know which relation
on relatedUser is the correct link to the users that the user has. I
considered having it guess or having an explicit rule saying that first
relationship is the correct one. Unfortunately there are cases where this
just might not be true. To fix this I added an *optional* attribute to the link that that
only needs to be used in cases like this. The attribute, alias, indicates
the aliasof the relationship to use on the linking object. Here’s
an example: <object name=”user”> <hasMany
name=”user”> <link
name=”relatedUser” alias=”relatedUser”> </hasMany> </object> <object name=”relatedUser”> <hasOne
name=”user”> <relate
from=”userId” to=”userId” /> </hasOne> <hasOne
name=”user” alias=”relatedUser”> <relate
from=”relatedUserId” to=”userId” /> </hasOne> </object> This will make it possible to relate fred to mike by simply
doing something like this: <cfset mike.getRelationIterator().add(fred) /> Any time you’re linking through an object and need to
specify the particular relationship to the related object then you can use the
optional alias attribute on the link tag. I can’t remember what the other fixes were. I suppose
I should keep a log! Doug |
- [Reactor For CF] Another few bug fixes Doug Hughes
- Re: [Reactor For CF] Another few bug fixes Jared Rypka-Hauer

