Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ public String getName() {
return tableName;
}
}

/** Metadata describing a schema. */
public static class MetaSchema implements Named {
@ColumnNoNulls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,82 @@ public Service create(AvaticaConnection connection) {
+ " \"parameters\": [],\n"
+ " \"cursorFactory\": {\"style\": \"ARRAY\"}\n"
+ "}}");
map1.put(
JsonService.encode(new TablesRequest(
connectionId, null, null, "additionalColumnsTest", Arrays.<String>asList())),
"{\"response\":\"resultSet\",\"connectionId\":\"" + connectionId + "\",\"statementId\":0,\"ownStatement\":true,"
+ "\"signature\":{\"columns\":["
+ "{\"ordinal\":0,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":0,\"signed\":false,"
+ " \"displaySize\":128,\"label\":\"TABLE_CAT\",\"columnName\":\"TABLE_CAT\",\"schemaName\":\"INFORMATION_SCHEMA\""
+ ",\"precision\":128,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\",\"catalogName\":\"PUBLIC\",\"type\":"
+ "{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,\""
+ "definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":1,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":0,\"signed\":false,"
+ "\"displaySize\":128,\"label\":\"TABLE_SCHEM\",\"columnName\":\"TABLE_SCHEM\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":128,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":2,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":0,\"signed\":false,"
+ "\"displaySize\":128,\"label\":\"TABLE_NAME\",\"columnName\":\"TABLE_NAME\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":128,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":3,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":0,\"signed\":false,"
+ "\"displaySize\":65536,\"label\":\"TABLE_TYPE\",\"columnName\":\"TABLE_TYPE\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":65536,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":4,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":65536,\"label\":\"REMARKS\",\"columnName\":\"REMARKS\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":65536,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":5,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":128,\"label\":\"TYPE_CAT\",\"columnName\":\"TYPE_CAT\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":128,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":6,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":128,\"label\":\"TYPE_SCHEM\",\"columnName\":\"TYPE_SCHEM\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":128,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":7,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":128,\"label\":\"TYPE_NAME\",\"columnName\":\"TYPE_NAME\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":128,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":8,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":128,\"label\":\"SELF_REFERENCING_COL_NAME\",\"columnName\":\"SELF_REFERENCING_COL_NAME\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":128,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":9,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":65536,\"label\":\"REF_GENERATION\",\"columnName\":\"REF_GENERATION\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":65536,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":10,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":128,\"label\":\"HSQLDB_TYPE\",\"columnName\":\"HSQLDB_TYPE\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":128,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\":11,\"autoIncrement\":false,\"caseSensitive\":false,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":5,\"label\":\"READ_ONLY\",\"columnName\":\"READ_ONLY\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":0,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":16,\"name\":\"BOOLEAN\",\"rep\":\"PRIMITIVE_BOOLEAN\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.Boolean\"},"
+ "{\"ordinal\":12,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":true,\"currency\":false,\"nullable\":1,\"signed\":false,"
+ "\"displaySize\":65536,\"label\":\"COMMIT_ACTION\",\"columnName\":\"COMMIT_ACTION\",\"schemaName\":\"INFORMATION_SCHEMA\",\"precision\":65536,\"scale\":0,\"tableName\":\"SYSTEM_TABLES\","
+ "\"catalogName\":\"PUBLIC\",\"type\":{\"type\":\"scalar\",\"id\":12,\"name\":\"VARCHAR\",\"rep\":\"STRING\"},\"readOnly\":true,\"writable\":false,"
+ "\"definitelyWritable\":false,\"columnClassName\":\"java.lang.String\"},"
+ "{\"ordinal\": 13,\"autoIncrement\": false,\"caseSensitive\": true,\"searchable\": true,\"currency\": false,\"nullable\": 1,\"signed\": false,"
+ "\"displaySize\": 65536,\"label\": \"EXTRA_LABEL\",\"columnName\": \"EXTRA_LABEL\",\"schemaName\": \"INFORMATION_SCHEMA\",\"precision\": 65536,\"scale\": 0,\"tableName\": \"SYSTEM_TABLES\","
+ "\"catalogName\": \"PUBLIC\",\"type\":{\"type\": \"scalar\",\"id\": 12,\"name\": \"VARCHAR\",\"rep\": \"STRING\"},\"readOnly\": true,\"writable\": false,"
+ "\"definitelyWritable\": false,\"columnClassName\": \"java.lang.String\"}],\"sql\":null,"
+ "\"parameters\":[],"
+ "\"cursorFactory\":{\"style\":\"LIST\",\"clazz\":null,\"fieldNames\":null},\"statementType\":null},"
+ "\"firstFrame\":{\"offset\":0,\"done\":true,"
+ "\"rows\":["
+ "[\"PUBLIC\",\"SCOTT\",\"DEPT\",\"TABLE\",null,null,null,null,null,null,\"MEMORY\",false,null,\"EXTRA_LABEL1\"],"
+ "[\"PUBLIC\",\"SCOTT\",\"EMP\",\"TABLE\",null,null,null,null,null,null,\"MEMORY\",false,null,\"EXTRA_LABEL2\"],"
+ "[\"PUBLIC\",\"SCOTT\",\"BONUS\",\"TABLE\",null,null,null,null,null,null,\"MEMORY\",false,null,\"EXTRA_LABEL3\"],"
+ "[\"PUBLIC\",\"SCOTT\",\"SALGRADE\",\"TABLE\",null,null,null,null,null,null,\"MEMORY\",false,null,null]]},"
+ "\"updateCount\":-1,\"rpcMetadata\":null}"
);
map1.put(
"{\"request\":\"closeStatement\",\"connectionId\":\"" + connectionId + "\",\"statementId\":0}",
"{\"response\":\"closeStatement\"}"
);
map1.put(
"{\"request\":\"getColumns\",\"connectionId\":\"" + connectionId + "\",\"catalog\":null,\"schemaPattern\":null,"
+ "\"tableNamePattern\":\"my_table\",\"columnNamePattern\":null}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,38 @@ private Map<Request, Response> createMapping() {
Meta.Frame.create(0, true,
Arrays.<Object>asList(new Object[] {new Object[]{"my_table", 10}})), -1, null));

mappings.put(
new TablesRequest(connectionId, null, null,
"additionalColumnsTest", Collections.<String>emptyList()),
// ownStatement=false just to avoid the extra close statement call.
new ResultSetResponse("0", 1, false,
Meta.Signature.create(
Arrays.<ColumnMetaData>asList(
MetaImpl.columnMetaData("TABLE_CAT", 0, String.class, true),
MetaImpl.columnMetaData("TABLE_SCHEM", 1, String.class, true),
MetaImpl.columnMetaData("TABLE_NAME", 2, String.class, true),
MetaImpl.columnMetaData("TABLE_TYPE", 3, String.class, true),
MetaImpl.columnMetaData("REMARKS", 4, String.class, true),
MetaImpl.columnMetaData("TYPE_CAT", 5, String.class, true),
MetaImpl.columnMetaData("TYPE_SCHEM", 6, String.class, true),
MetaImpl.columnMetaData("TYPE_NAME", 7, String.class, true),
MetaImpl.columnMetaData("SELF_REFERENCING_COL_NAME", 8, String.class, true),
MetaImpl.columnMetaData("REF_GENERATION", 9, String.class, true),
MetaImpl.columnMetaData("HSQLDB_TYPE", 10, String.class, true),
MetaImpl.columnMetaData("READ_ONLY", 11, Boolean.class, true),
MetaImpl.columnMetaData("COMMIT_ACTION", 12, String.class, true),
MetaImpl.columnMetaData("EXTRA_LABEL", 13, Boolean.class, true)),
null, null, Meta.CursorFactory.ARRAY, Meta.StatementType.SELECT),
Meta.Frame.create(0, true,
Arrays.<Object>asList(
new Object[] {"table_cat", "table_schem", "table_name", "table_type", "remarks",
"type_cat", "type_schem", "type_name", "self_referencing_col_name",
"ref_generation", "hsqldb_type", true, "commit_action", "extra_label1"},
new Object[] {"table_cat", "table_schem", "table_name", "table_type",
"remarks", "type_cat", "type_schem", "type_name", "self_referencing_col_name",
"ref_generation", "hsqldb_type", false, "commit_action", "extra_label2"}
)), -1, null));

return Collections.unmodifiableMap(mappings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,21 @@ private Connection getMockConnection() {
connection.close();
}

@Test public void testTablesAdditionalColumns() throws Exception {
final Connection connection = getMockConnection();
final ResultSet resultSet =
connection.getMetaData().getTables(null, null, "additionalColumnsTest", new String[0]);
assertTrue(resultSet.next());
final ResultSetMetaData metaData = resultSet.getMetaData();
assertTrue(metaData.getColumnCount() == 14);
assertEquals("TABLE_CAT", metaData.getColumnName(1));
assertEquals("TABLE_SCHEM", metaData.getColumnName(2));
assertEquals("TABLE_NAME", metaData.getColumnName(3));
assertEquals("EXTRA_LABEL", metaData.getColumnName(14));
resultSet.close();
connection.close();
}

@Ignore
@Test public void testNoFactory() throws Exception {
final Connection connection =
Expand Down