Permalink
Browse files

Add recognition of MQTs and ALIASes as table types for DB2

  • Loading branch information...
1 parent c2a1395 commit 0e7d069697241eb93b6574f3ce69cfe3a60e74ed Mike Virata-Stone and Samer Abukheit committed with onsitedev Apr 10, 2012
View
BIN lib/arjdbc/jdbc/adapter_java.jar
Binary file not shown.
View
7 src/java/arjdbc/db2/DB2RubyJdbcConnection.java
@@ -37,11 +37,18 @@
* @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;
}
View
8 src/java/arjdbc/jdbc/RubyJdbcConnection.java
@@ -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;
@@ -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();
@@ -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");
}

0 comments on commit 0e7d069

Please sign in to comment.