Is "alias" reserved?


#1

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}”’
end

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?

thanks!


#2

Yeah, alias is a reserved word.

You might find
http://www.ilovejackdaniels.com/ruby_on_rails_cheat_sheet.png
helpful.

Pat


#3

Pat M. wrote:

Yeah, alias is a reserved word.

You might find
http://www.ilovejackdaniels.com/ruby_on_rails_cheat_sheet.png
helpful.

Pat

Thanks, Pat.
That’s an awesome resource.

:slight_smile: