Unconfigured schema (username) is not handled in Oracle
-------------------------------------------------------

                 Key: JRUBY-3669
                 URL: http://jira.codehaus.org/browse/JRUBY-3669
             Project: JRuby
          Issue Type: Bug
          Components: ActiveRecord-JDBC
    Affects Versions: ActiveRecord-JDBC-0.9.1
            Reporter: Dan Powell
             Fix For: ActiveRecord-JDBC-0.9.2
         Attachments: jruby-3669.patch

When no username is specified (as in JNDI configurations) the schema is 
specified as an empty String for MetaData operations.  The below patch properly 
passes null fort he schema name in these situations.  Also available as a pull 
request in GitHub from dpowell.

diff --git a/lib/jdbc_adapter/jdbc_oracle.rb b/lib/jdbc_adapter/jdbc_oracle.rb
index bcebbe9..9bcf403 100644
--- a/lib/jdbc_adapter/jdbc_oracle.rb
+++ b/lib/jdbc_adapter/jdbc_oracle.rb
@@ -356,7 +356,7 @@ module ::JdbcSpec
     # In Oracle, schemas are created under your username:
     # http://www.oracle.com/technology/obe/2day_dba/schema/schema.htm
     def oracle_schema
-      @config[:username].to_s
+      @config[:username].to_s if @config[:username]
     end
 
     def select(sql, name=nil)
diff --git a/src/java/jdbc_adapter/RubyJdbcConnection.java 
b/src/java/jdbc_adapter/RubyJdbcConnection.java
index c2026a4..558d9f6 100644
--- a/src/java/jdbc_adapter/RubyJdbcConnection.java
+++ b/src/java/jdbc_adapter/RubyJdbcConnection.java
@@ -130,7 +130,7 @@ public class RubyJdbcConnection extends RubyObject {
 
                     DatabaseMetaData metadata = c.getMetaData();
 
-                    if(args.length > 2) schemaName = args[2].toString();
+                    if(args.length > 2) schemaName = toStringOrNull(args[2]);
 
                     if (schemaName != null) schemaName = 
caseConvertIdentifierForJdbc(metadata, schemaName);
                     table_name = caseConvertIdentifierForJdbc(metadata, 
table_name);



-- 
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