Skip to content

Commit

Permalink
Add recognition of MQTs and ALIASes as table types for DB2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Virata-Stone and Samer Abukheit authored and onsitedev committed Apr 10, 2012
1 parent c2a1395 commit 0e7d069
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Binary file modified lib/arjdbc/jdbc/adapter_java.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions src/java/arjdbc/db2/DB2RubyJdbcConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@
* @author mikestone
*/
public class DB2RubyJdbcConnection extends RubyJdbcConnection {
private static final String[] TABLE_TYPES = new String[]{"TABLE", "VIEW", "SYNONYM", "MATERIALIZED QUERY TABLE", "ALIAS"};

protected DB2RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
super(runtime, metaClass);
}

@Override
protected String[] getTableTypes() {
return TABLE_TYPES;
}

@Override
protected boolean databaseSupportsSchemas() {
return true;
Expand Down
8 changes: 6 additions & 2 deletions src/java/arjdbc/jdbc/RubyJdbcConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
*/
public class RubyJdbcConnection extends RubyObject {
private static final String[] TABLE_TYPE = new String[]{"TABLE"};
private static final String[] TABLE_TYPES = new String[]{"TABLE", "VIEW", "SYNONYM"};

private static RubyObjectAdapter rubyApi;

Expand Down Expand Up @@ -104,6 +105,10 @@ protected static RubyModule getConnectionAdapters(Ruby runtime) {
return (RubyModule) runtime.getModule("ActiveRecord").getConstant("ConnectionAdapters");
}

protected String[] getTableTypes() {
return TABLE_TYPES;
}

@JRubyMethod(name = "begin")
public IRubyObject begin(ThreadContext context) throws SQLException {
final Ruby runtime = context.getRuntime();
Expand All @@ -126,9 +131,8 @@ public Object call(Connection c) throws SQLException {
String tableName = rubyApi.convertToRubyString(args[0]).getUnicodeValue();
TableNameComponents components = extractTableNameComponents(c, defaultSchema, tableName);

String[] tableTypes = new String[]{"TABLE","VIEW","SYNONYM"};
RubyArray matchingTables = (RubyArray) tableLookupBlock(context.getRuntime(),
components.catalog, components.schema, components.table, tableTypes, false).call(c);
components.catalog, components.schema, components.table, getTableTypes(), false).call(c);
if (matchingTables.isEmpty()) {
throw new SQLException("Table " + tableName + " does not exist");
}
Expand Down

0 comments on commit 0e7d069

Please sign in to comment.