H2 Database - JdbcConnection#columns returns results from multiple schemas
--------------------------------------------------------------------------

                 Key: JRUBY-1642
                 URL: http://jira.codehaus.org/browse/JRUBY-1642
             Project: JRuby
          Issue Type: Bug
          Components: ActiveRecord-JDBC
    Affects Versions: JRuby 1.0.2
         Environment: JRuby 1.0.2, activerecord-1.15.6, 
activerecord-jdbc-adapter-0.6, h2 database 1.0.61
            Reporter: Alon Salant


Using H2 Database, JdbcConnection#columns is returning column names from both 
INFORMATION_SCHEMA and PUBLIC. This results in all tables having the additional 
columns "name, admin, remarks, id" which breaks 
ActiveRecord::Base#create/save/....

This appears to be related to other bugs regarding multiple schema names in 
Oracle like: JRUBY-1254, JRUBY-1638, JRUBY-1115

Here is a script that will reproduce this error:

{code}
require 'java'
require 'rubygems'
gem 'activerecord-jdbc-adapter'
require 'jdbc_adapter'
require 'active_record'

def connect()
  conf = { :adapter => 'jdbc', :driver => 'org.h2.Driver',
           :url => 'jdbc:h2:mem:jruby_test;DB_CLOSE_DELAY=5',
           :username => 'root', :password => ''}
  ActiveRecord::Base.establish_connection(conf)
end

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
    end
  end
end

class User < ActiveRecord::Base
end

connect
CreateUsers.up

puts User.column_names.join(', ')

#User.create!()
User.find(:all).each do |user|
  puts user
end
{code}

The output of the 'puts' line for me is:

{noformat}
name, admin, remarks, id, id
{noformat}

The User.create! statement fails because it attempts to use these additional 
columns.

I'm happy to dig into producing a fix. Please provide a pointer to where this 
behavior should be handled.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to