On Wed, May 11, 2005 at 03:07:29PM -0400, Guest via RT wrote:
Show quoted text> > > In section:table_alias
> > > package Shop::Order;
> > > __PACKAGE__->table('orders'); # XXX should be 'order'
> > > __PACKAGE__->table_alias('orders');
> > Erm, no, it shouldn't. The entire point is that 'order' is a reserved
> > word in SQL.
> If the table is called 'order' then you need to set an alias for it
> called 'orders' because it is a reserved word. That IS my point. Why is
> it 'orders' and aliased as 'orders'. Look closer.
You're not understanding the point of this method.
'order' is a reserved word in SQL, so you can't have a table called
that. The table *is* called 'orders'.
However, because the *class* is called Shop::Order, and thus has a
moniker of 'order', the SQL that Class::DBI would generate, in the case
of a multi-table join, would be invalid, as it aliases the table name
to the moniker of the class.
So, in this case, you need to tell it that the *alias* for the table
needs to be something other than the moniker, in this case 'orders'.
Tony