Forum: Ruby on Rails is "alias" reserved?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dave C. (Guest)
on 2006-03-06 02:51
I'm playing with an online store....

I have an orders table which holds orders (pricing, statuses, etc).
An orderDetails table which holds detailed line items (itemNumbers, unit
prices, etc).

Each order can have multiple shipping addresses, so I also have
an addressbook table. Each orderDetail is tied to an addressbook entry
via the ordernumber and addressbook alias, but this doesn't seem to work
for me.

class OrderDetail < ActiveRecord::Base
set_table_name "orderDetails"
belongs_to :order, :foreign_key => 'orderNumber'
has_many :addressbooks, :finder_sql =>
      'SELECT * ' +
      'FROM addressbooks addr ' +
      'WHERE addr.orderNumber = "#{orderNumber}"' +
      'AND addr.alias = "#{alias}"'

I try to access the addressbook of a specific orderDetail (line item)
and it barfs.


(eval):1:in `instance_eval': compile error
(eval):1: syntax error
%@SELECT * FROM addressbooks addr WHERE addr.orderNumber =
"#{orderNumber}" AND addr.alias = "#{alias}"@
(eval):1: unterminated string meets end of file


Just wondering if the word "alias" is a reserved word
for either mysql or rails?

Pat M. (Guest)
on 2006-03-06 02:57
(Received via mailing list)
Yeah, alias is a reserved word.

You might find

Dave C. (Guest)
on 2006-03-06 03:03
Pat M. wrote:
> Yeah, alias is a reserved word.
> You might find
> helpful.
> Pat

Thanks, Pat.
That's an awesome resource.

This topic is locked and can not be replied to.