Bugs item #18604, was opened at 2008-03-04 22:05
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=7857&aid=18604&group_id=2014
Category: AR-JDBC
Group: 0.2.3
Status: Closed
Resolution: None
Priority: 3
Submitted By: Greg Orlowski (gregorlowski)
Assigned to: Nobody (None)
Summary: activerecord-jdbc does not handle schemaname.tablename naming
construct with mysql
Initial Comment:
In rails with MRI + MySQL, we are able to use the following construct for
setting table names in our model classes:
set_table_name "#{databasename}.tablename"
where databasename represents a MySQL database (schema). We need to do this
because our app spans multiple databases (legacy db), and different model
classes reference different schemas (effectively databases in MySQL).
In JRuby with activerecord-jdbcmysql-adapter-0.7.2, (warbler deployed on
tomcat), we get the error (as a rails error page):
Table databasename. does not exist
(where databasename is the name of our dbschema).
I confirmed that if I remove the schema name, I can run a subset of our app
with the model classes that use the schema named as the default schema in
database.yml (in the database: section).
Rails version: 1.2.6
Gems Versions:
activerecord-jdbc-adapter-0.7.2
activerecord-jdbcmysql-adapter-0.7.2
Jars:
mysql-connector-java-5.0.4-bin.jar
jruby-complete-1.1RC2.jar
goldspike-1.5.jar
database.yml
development:
adapter: jdbcmysql
database: ourdbname
username: ouruser
password: ourpass
host: 127.0.0.1
I do have this in my environment.rb:
if RUBY_PLATFORM =~ /java/
require 'rubygems'
RAILS_CONNECTION_ADAPTERS = %w(jdbcmysql)
require 'active_record'
gem 'activerecord-jdbcmysql-adapter'
require 'active_record/connection_adapters/jdbcmysql_adapter'
end
----------------------------------------------------------------------
>Comment By: Nick Sieger (nicksieger)
Date: 2010-05-13 09:03
Message:
Whoops, didn't mean to use the canned message. Meant to say that I think this
is fixed now:
http://kenai.com/jira/browse/ACTIVERECORD_JDBC-116
----------------------------------------------------------------------
Comment By: Nick Sieger (nicksieger)
Date: 2010-05-13 09:03
Message:
Hi, we no longer use this tracker to track bugs here. Can you
please file a copy of this bug at
http://kenai.com/jira/browse/ACTIVERECORD_JDBC ?
Thanks!
----------------------------------------------------------------------
Comment By: Dilshod Mukhtarov (dilshodm)
Date: 2010-03-07 04:29
Message:
I faced same problem with activerecord-jdbc-adapter-0.9.3
The following is a patch that solves problem.
diff -Nru
activerecord-jdbc-adapter-0.9.3/src/java/jdbc_adapter/RubyJdbcConnection.java
activerecord-jdbc-adapter-0.9.3.new/src/java/jdbc_adapter/RubyJdbcConnection.java
---
activerecord-jdbc-adapter-0.9.3/src/java/jdbc_adapter/RubyJdbcConnection.java
2009-10-26 23:25:01.000000000 +0300
+++
activerecord-jdbc-adapter-0.9.3.new/src/java/jdbc_adapter/RubyJdbcConnection.java
2010-03-07 10:35:12.000000000 +0300
@@ -135,14 +135,17 @@
if (schemaName != null) schemaName =
caseConvertIdentifierForJdbc(metadata, schemaName);
table_name = caseConvertIdentifierForJdbc(metadata,
table_name);
+ String catalog = c.getCatalog();
+ if (schemaName != null) { catalog = schemaName; }
+
String[] tableTypes = new
String[]{"TABLE","VIEW","SYNONYM"};
RubyArray matchingTables = (RubyArray)
tableLookupBlock(context.getRuntime(),
- c.getCatalog(), schemaName, table_name,
tableTypes, false).call(c);
+ catalog, schemaName, table_name, tableTypes,
false).call(c);
if (matchingTables.isEmpty()) {
throw new SQLException("Table " + table_name + " does
not exist");
}
- results =
metadata.getColumns(c.getCatalog(),schemaName,table_name,null);
+ results =
metadata.getColumns(catalog,schemaName,table_name,null);
return unmarshal_columns(context, metadata, results);
} finally {
close(results);
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=7857&aid=18604&group_id=2014
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel