lbehnke / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

JDBC: accessing table meta-data not case-insensitive (connection.getMetaData().getTables()) #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
-- snip
  @Test
  public void testCaseInsensitive() throws SQLException {
    Connection con;
    ResultSet  data;

    con = DriverManager.getConnection("jdbc:h2:mem:;IGNORECASE=TRUE");

    con.prepareCall("CREATE TABLE test_table(" +
            "test_table_id INT NOT NULL PRIMARY KEY, " +
            "test_smallint SMALLINT)").execute();
    con.prepareCall("INSERT INTO test_table VALUES (1, 10)").executeUpdate();
    con.prepareCall("INSERT INTO tEsT_tAblE VALUES (2, 20)").executeUpdate();

    // works
    data = con.prepareCall("SELECT * from test_table").executeQuery();
    data.next();
    assertEquals(1, data.getInt(1));
    assertEquals(10, data.getInt(2));
    data.next();
    assertEquals(2, data.getInt(1));
    assertEquals(20, data.getInt(2));
    data.close();

    // works
    data = con.prepareCall("SELECT * from TEST_table").executeQuery();
    data.next();
    assertEquals(1, data.getInt(1));
    assertEquals(10, data.getInt(2));
    data.next();
    assertEquals(2, data.getInt(1));
    assertEquals(20, data.getInt(2));
    data.close();

    // works
    data = con.getMetaData().getTables(null, null, "TEST_TABLE", null);
    assertEquals(true, data.next());
    data.close();
    // FAILS!!!
    data = con.getMetaData().getTables(null, null, "test_table", null);
    assertEquals(true, data.next());
    data.close();
  }
-- snap

What is the expected output? What do you see instead?
expected output of call con.getMetaData().getTables(null, null,
"test_table", null) is the meta-data of table "test_table".
Instead, no table is found.

What version of the product are you using? On what operating system, file
system, and virtual machine?
h2: h2-1.1.118
os: Mac OS X 10.5.8
vm: JVM 1.6.0

Do you know a workaround?

call con.getMetaData().getTables(null, null, "test_table".toUpperCase(),
null); instead

How important/urgent is the problem for you?

stumbled over it when testing different jdbc clients with my software. as
long as the workaround works with all clients, it's not urgent.

In your view, is this a defect or a feature request?

defect, since IGNORECASE=TRUE is passed in the jdbc-url.

Please provide any additional information below.

Original issue reported on code.google.com by martin.h...@gmail.com on 29 Oct 2009 at 12:46

GoogleCodeExporter commented 9 years ago
Hi,

In my view this is not a bug. See
http://www.h2database.com/html/grammar.html#set_ignorecase "If IGNORECASE is 
enabled,
text columns in newly created tables will be case-insensitive.". This feature 
is not
related to JDBC method calls. See also:

http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#storesUpper
CaseIdentifiers()
"Retrieves whether this database treats mixed case unquoted SQL identifiers as 
case
insensitive and stores them in upper case. "

http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getTables(j
ava.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String[])
"tableNamePattern - a table name pattern; must match the table name as it is 
stored
in the database"

So I set this issue to 'Wont Fix'. Please tell me if you don't agree.

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 1 Nov 2009 at 5:05