Bugs item #14478, was opened at 2007-10-05 06:28
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=7857&aid=14478&group_id=2014

Category: AR-JDBC
Group: 0.2.3
Status: Open
Resolution: None
Priority: 3
Submitted By: Nobody (None)
Assigned to: Nobody (None)
Summary: (solution provided) Oracle table names with schemas handled 
incorrectly .

Initial Comment:
When you try to do this:
  set_table_name "schema.tablename" 
with the Oracle adapter, scaffolding and other table info-gathering functions 
break. 

SVN commit #738 implements a fix for this problem in Postgres, and since the 
same problem exists for Oracle, I tried it and it fixed the oracle adapter.

Just override the columns method as in Postgres fix #738 with the following:

    def columns(table_name, name=nil)
      if table_name =~ /\./
        parts = table_name.split(/\./)
        table_name = parts.pop
        schema_name = parts.join(".")
            @connection.columns_internal(table_name, name, schema_name)
      else
            @connection.columns_internal(table_name, name)
      end
    end


Regards,
Bernie

P.S. I tried submitting this to the Dev mailing list...anybody get that email?

----------------------------------------------------------------------

Comment By: Eric Gascoine (gencom-encana)
Date: 2008-01-10 19:17

Message:
This was very informative, and thanks, here's a fix to make it work 
consistently for schema names and to put it into context for less experienced 
developers:  in environment.rb:. 

if RUBY_PLATFORM =~ /java/
    require 'rubygems'
    gem 'activerecord-jdbc-adapter', ">=0.7"
    require 'jdbc_adapter'
  
    # the following is a hack to fix inserts for
    # activerecord-jdbc-adapter 0.7
    module ::JdbcSpec
        module Oracle
           def columns(table_name, name=nil)
                if table_name =~ /\./
                    parts = table_name.split(/\./)
                    my_table_name = parts.pop
                    schema_name = parts.join(".")
                    @connection.columns_internal(my_table_name, name, 
schema_name.upcase)
                else
                    @connection.columns_internal(table_name, name)
                end
            end
        end
    end
end



----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=7857&aid=14478&group_id=2014
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to