Skip to content

Commit

Permalink
Fix problems introduced by commit aa760d4 - Overriding the catalog wi…
Browse files Browse the repository at this point in the history
…th the schema will break a MS SQL server database which uses schemas
  • Loading branch information
jcosmo authored and unknown committed May 31, 2010
1 parent 273f6c5 commit 72e5dc2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/java/jdbc_adapter/MssqlRubyJdbcConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,13 @@ protected IRubyObject jdbcToRuby(Ruby runtime, int column, int type, ResultSet r
}
return super.jdbcToRuby(runtime, column, type, resultSet);
}

/**
* SqlServer supports schemas so lets not go using the schema name as the catalog name
*/
@Override
protected boolean databaseSupportsSchemas()
{
return true;
}
}
8 changes: 7 additions & 1 deletion src/java/jdbc_adapter/RubyJdbcConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public Object call(Connection c) throws SQLException {
table_name = caseConvertIdentifierForJdbc(metadata, table_name);

String catalog = c.getCatalog();
if (schemaName != null) { catalog = schemaName; }

if (schemaName != null && !databaseSupportsSchemas()) { catalog = schemaName; }

String[] tableTypes = new String[]{"TABLE","VIEW","SYNONYM"};
RubyArray matchingTables = (RubyArray) tableLookupBlock(context.getRuntime(),
Expand Down Expand Up @@ -1173,4 +1174,9 @@ public static ColumnData[] setup(Ruby runtime, DatabaseMetaData databaseMetadata
return columns;
}
}

protected boolean databaseSupportsSchemas()
{
return false;
}
}

0 comments on commit 72e5dc2

Please sign in to comment.