Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #81 from leonardlin/master
[CONJ-218] DatabaseMetaData.getTables() returned "BASE TABLE" as TABLE TYPE
  • Loading branch information
rusher committed May 5, 2016
2 parents fa6fd29 + 4e8c715 commit 747d265
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions documentation/Developers-Guide.md
Expand Up @@ -34,9 +34,9 @@ You can change those parameter by adding -DdbUrl parameter. like :

mvn test -DdbUrl=jdbc:mariadb://127.0.0.1:3306/testj?user=root&password=*****

You can launch a specific test by adding -Dfile
You can launch a specific test by adding -Dtest

mvn test -Dfile=org.mariadb.jdbc.JdbcParserTest
mvn test -Dtest=org.mariadb.jdbc.JdbcParserTest

When all test are passing, you can package project.
Additional tests , like javadoc formatting, code style validation will be done :
Expand Down
Expand Up @@ -540,7 +540,7 @@ public ResultSet getTables(String catalog, String schemaPattern, String tableNam
throws SQLException {

String sql =
"SELECT TABLE_SCHEMA TABLE_CAT, NULL TABLE_SCHEM, TABLE_NAME, TABLE_TYPE, TABLE_COMMENT REMARKS,"
"SELECT TABLE_SCHEMA TABLE_CAT, NULL TABLE_SCHEM, TABLE_NAME, IF(TABLE_TYPE='BASE TABLE', 'TABLE', TABLE_TYPE) as TABLE_TYPE, TABLE_COMMENT REMARKS,"
+ " NULL TYPE_CAT, NULL TYPE_SCHEM, NULL TYPE_NAME, NULL SELF_REFERENCING_COL_NAME, "
+ " NULL REF_GENERATION"
+ " FROM INFORMATION_SCHEMA.TABLES "
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java
Expand Up @@ -347,6 +347,26 @@ public void testGetTables2() throws SQLException {

}

@Test
public void testGetTables3() throws SQLException {
Statement stmt = sharedConnection.createStatement();
stmt.execute("drop table if exists table_type_test");

stmt.execute("create table table_type_test (id int not null primary key, "
+ "val varchar(20)) engine=innodb");

DatabaseMetaData dbmd = sharedConnection.getMetaData();
ResultSet tableSet = dbmd.getTables(null, null, "table_type_test", null);

assertEquals(true, tableSet.next());

String tableName = tableSet.getString("TABLE_NAME");
assertEquals("table_type_test", tableName);

String tableType = tableSet.getString("TABLE_TYPE");
assertEquals("TABLE", tableType); // see for possible values https://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getTableTypes%28%29
}

@Test
public void testGetColumns() throws SQLException {
DatabaseMetaData dbmd = sharedConnection.getMetaData();
Expand Down

0 comments on commit 747d265

Please sign in to comment.