|
yeaaahhh!
this sounds rad, and you did it so quickly! When I
brought this up on the list a while back I thought it would take longer for you
to fit it into your schedule. You da man!
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Doug Hughes Sent: Sunday, February 26, 2006 6:09 PM To: [email protected] Subject: [Reactor For CF] New features: Table and Field aliases Hey
all, I thought I should let you know that
I rolled out two much-requested feature today: Table aliases and Field
aliases. First off, this really shouldn’t
break any existing code. The framework should just work. However,
the update did, in fact, touch almost every file in reactor. I suggest
that you delete everything under the /reactor/project folder and start
fresh. There were also some changes to the custom objects, but don’t
bother recreating them, the changes only involved names.
So, because this touched so much I
really need people to test this feature and report things that did work, but
which no longer work. That said, here’s the rundown on the
new features: Table Aliases. Typically you’d
add an object in your reactor.xml like this: <object name="Category"
/> However, what if you have a legacy
table name? IE: tbl_Cat It’d suck to have you create an instance of
that object. It’s ugly. Or, what if your tables are plural?
IE: customers. Then you’d be stuck creating a CustomersRecord, which is
obnoxious. So, now you can add an alias to that
tag: <object name="tbl_Cat"
alias=”Category” /> Or <object name=”Customers”
alias=”Customer” /> Now you can use the reactorFactory
to create an instance of a Category or Customer record. The files on disk
get the aliased name too. Note: Anywhere you don’t
provide an alias, the alias is implicitly created as the item’s name.
Thus, the following example actually gets an alias of Category. This is
true across all of reactor. <object name="Category" />
Any time you create a relationship
you must set the relationship’s name as the target object’s alias. For
example, let’s say you three tables, tblEntry, tblEntryCategory and
tblCategory. tblEntryCategory hasOne of both tblEntry and
tblCategory. tblEntry and tblCategory haveMany of each over via
tblEntryCategory. If you wanted to alias these objects to get rid of your
tbl prefix your xml would look like this: <objects>
<object name="tblEntry" alias="Entry">
<hasMany name="Category">
<link name="EntryCategory" />
</hasMany>
</object>
<object name="tblEntryCategory"
alias="EntryCategory">
<hasOne name="Entry">
<relate from="entryId" to="entryId" />
</hasOne>
<hasOne name="Category">
<relate from="categoryId" to="categoryId" />
</hasOne>
</object>
<object name="tblCategory" alias="Category">
<hasMany name="Entry">
<link name="EntryCategory" />
</hasMany>
</object> </objects> Why do I use the name attribute on
the hasmany/hasone tags? Because these tags also have aliases. So, I
could rename a specific relationship. IE: <object name="tblCategory"
alias="Category">
<hasMany name="Entry" alias=”Article”>
<link name="EntryCategory" />
</hasMany> </object> Field Aliases. I also
introduced field aliases. Field aliases let you rename fields in your
objects. For example, you might have a column named colIntCatId.
Maybe you want this addressed as categoryId in your application. To do
this you add field tags inside your object tags. For
example: <object name="tblEntry"
alias="Entry"> <field name=”colIntCatId”
alias=”categoryId” /> <hasMany
name="Category">
<link
name="EntryCategory" />
</hasMany> </object> Doing this will cause the properties
in the TO use the alias, the get/setters on your records to use the alias, it
will show up in the metadata, and your queries will return that column
name. It’s actually petty slick! Any fields you don’t define aliases
for will implicitly be given an alias the same as their
name. So, please, get latest. Test
this out. If you find any issues please let me know. If something
seems funny with these features, please let me know! This is a BIG update
and there are likely to be bugs in it. Next On
Tap: -
A solution to the Oracle issues
(sorry to keep you waiting Beth) -
A DB2
driver -
A Postgres
driver -
Updated
validation -
A real fix for mssql default value
problems. Thanks, Doug |
- [Reactor For CF] New features: Table and Field aliases Doug Hughes
- Re: [Reactor For CF] New features: Table and Field al... Dave Shuck
- SV: [Reactor For CF] New features: Table and Field a... Tormod Boga
- RE: [Reactor For CF] New features: Table and Field a... Daniel Short
- Re: [Reactor For CF] New features: Table and Field al... Sean Corfield
- RE: [Reactor For CF] New features: Table and Field a... Chris Blackwell
- RE: [Reactor For CF] New features: Table and Field a... Miller, Ryan

