I was running into trouble doing something like this with JRuby
(1.1RC3), activerecord (2.0.2), activerecord-jdbc-adapter (0.8), Oracle
10g (10.2.0.2.0), and the Oracle JDBC Thin Driver (9.2.0.1.0):

class Person < ActiveRecord::Base
  set_table_name 'dls.my_contacts'
end

I made the following changes to JdbcAdapterInternalService.java and
things seem to be better (in Oracle at least).  The problems were that
table and schema were transposed, schema included the period (i.e. ".")
and was not getting uppercased to match the meta data coming from
Oracle.  I know I should include some tests to validate I haven't broken
anything but maybe some kind person with the other databases installed
could help me out with that?

Hope this helps,
Darcy.


Index:
D:/ws/head/activerecord-jdbc/src/java/jdbc_adapter/JdbcAdapterInternalSe
rvice.java
===================================================================
---
D:/ws/head/activerecord-jdbc/src/java/jdbc_adapter/JdbcAdapterInternalSe
rvice.java      (revision 955)
+++
D:/ws/head/activerecord-jdbc/src/java/jdbc_adapter/JdbcAdapterInternalSe
rvice.java      (working copy)
@@ -411,8 +411,8 @@
                     String schemaName = null;
 
                     if(table_name.indexOf(".") != -1) {
-                        schemaName =
table_name.substring(table_name.indexOf(".")+1);
-                        table_name = table_name.substring(0,
table_name.indexOf(".")+1);
+                        schemaName = table_name.substring(0,
table_name.indexOf("."));
+                        table_name =
table_name.substring(table_name.indexOf(".")+1);
                     }
 
                     DatabaseMetaData metadata = c.getMetaData();
@@ -426,8 +426,10 @@
 
                     if(metadata.storesUpperCaseIdentifiers()) {
                         table_name = table_name.toUpperCase();
+                        schemaName = schemaName.toUpperCase();
                     } else if(metadata.storesLowerCaseIdentifiers()) {
                         table_name = table_name.toLowerCase();
+                        schemaName = schemaName.toLowerCase();
                     }
 
                     if(schemaName == null && (isDerby || isOracle)) {

This email communication and any files transmitted with it may contain 
confidential and or proprietary information and is provided for the use of the 
intended recipient only. Any review, retransmission or dissemination of this 
information by anyone other than the intended recipient is prohibited.  If you 
receive this email in error, please contact the sender and delete this 
communication and any copies immediately. Thank you. 
http://www.encana.com


_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to