Schema:
create_table "Bugs" do |t|
end
Models:
class Bug < ActiveRecord::Base
set_table_name "Bugs"
end
Bug.last gives the following error:
ActiveRecord::StatementInvalid: OCIError: ORA-00904: "BUGS"."ID":
invalid identifier: select * from (select raw_sql_.*, rownum raw_rnum_
from (SELECT * FROM "Bugs" ORDER BY Bugs.id DESC) raw_sql_ where
rownum <= 1) where raw_rnum_ > 0
It appears that the table name is not being quoted properly in
the ORDER BY clause. Bug.first doesn't give an error. It works
fine if the table name is "bugs" or "BUGS" instead.
Versions:
activerecord (2.3.5)
activerecord-oracle_enhanced-adapter (1.2.4)
ruby-oci8 (2.0.3)
I think it will work correctly in Rails 3 as there SQL generation is
rewritten to use Arel gem and it will quote table names correctly in
all places.
Raimonds
Thanks.
On Feb 28, 4:09 am, Raimonds Simanovskis
CREATE OR REPLACE SYNONYM bugs FOR "Bugs"
or include in migration
add_synonym :bugs, "Bugs"
and then you can use "bugs" as table name for your model class.