 |
Forums |
Admin Start New Thread
By: Bryan Evans
RE: Oracle: undefined method `[]' ... [ reply ] 2007-01-03 21:49
|
After an unexpected delay, I released a fix for this problem this morning (gem version 0.1.8).
The main issue is that table names in Oracle are case-sensitive. Oracle uppercases all table names unless quotes are used in the CREATE TABLE statement
ex1. CREATE TABLE "employees" will result in a lowercase table name
ex2. CREATE TABLE employees will result in an uppercase table name (EMPLOYEES)
The Rails Oracle adapter uses lowercase table names in the framework and converts them to uppercase when querying the DB. DrySQL now follows this same pattern, which solves the problem described at the beginning of this thread.
The standard Rails Oracle adapter does not currently support lowercase table names, so DrySQL's extension to the Rails Oracle adapter will assume that Oracle table names are always uppercased for now.
|
By: Bryan Evans
RE: Oracle: undefined method `[]' ... [ reply ] 2006-12-20 16:25
|
This is indeed a bug. The issue is case-sensitivity in Oracle.
I should have a fix out in the next day or 2, but in the meantime there are 2 workarounds:
1) Name your tables with lowercase letters only
2) Define a class for each table and call set_table_name in each (eg. set_table_name "EMPS")
Cheers.
|
By: jean-pierre laberlue
RE: Oracle: undefined method `[]' ... [ reply ] 2006-12-20 09:40
|
Here is the DDL:
CREATE TABLE EMPS (
EMP_ID INTEGER NOT NULL,
EMP_NAME VARCHAR2 (64),
CONSTRAINT PK_EMP
PRIMARY KEY ( EMP_ID ) ) ;
And here is my code:
# require & connect ...
e = Emp.find(:all)
puts e.size
As you see, this is very simple. I have just noted that the code works with drysql if the table is empty. Here is the output:
DRYSQL >> GENERATED CLASS: Emp < ActiveRecord::Base
0
|
By: Bryan Evans
RE: Oracle: undefined method `[]' ... [ reply ] 2006-12-19 19:33
|
Hi Jean-Pierre
I took a quick look through DrySQL's oracle adapter, and it appears that DrySQL will fail with the above error if your table does not have a primary key defined for it. If I'm on the wrong track and your table does have a PK defined on it, please post the DDL for the table that causes the above error and I'll investigate further.
Cheers.
|
By: jean-pierre laberlue
Oracle: undefined method `[]' ... [ reply ] 2006-12-19 17:05
|
Hi,
Just tried drysql with Oracle 9g2. I get this error message but does not know how to debug. The schema is very simple and it works fine if I create the object explicitly (without drysql reflection).
c:/opt/ruby/lib/ruby/gems/1.8/gems/drysql-0.1.7/lib/connection_adapters/oracle_adapter.rb:76:in `columns': undefined method `[]' for nil:NilClass
(NoMethodError)
from c:/opt/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:696:in `columns'
from c:/opt/ruby/lib/ruby/gems/1.8/gems/drysql-0.1.7/lib/validations.rb:76:in `generate_validations'
from c:/opt/ruby/lib/ruby/gems/1.8/gems/drysql-0.1.7/lib/base.rb:73:in `instantiate'
from c:/opt/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:390:in `find_by_sql'
from c:/opt/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:390:in `find_by_sql'
from c:/opt/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:924:in `find_every'
from c:/opt/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:381:in `find'
from ar_ora.rb:15
Press any key to continue . . .
|
|
 |