~maria-captains/mariadb-java-client/trunk

« back to all changes in this revision

Viewing changes to src/test/java/org/mariadb/jdbc/DatabaseMetadataTest.java

  • Committer: Vladislav Vaintroub
  • Date: 2013-09-20 14:55:18 UTC
  • Revision ID: wlad@montyprogram.com-20130920145518-ee3ys2xsr1c5ci0x
CONJ-66 : Extra rows (index parts that are not not parts of primary keys)  may be returned by DatabaseMetaData.getPrimaryKeys()

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
        }
40
40
        assertEquals(2,i);
41
41
    }
 
42
 
 
43
    @Test
 
44
    public void primaryKeyTest2() throws SQLException {
 
45
        Statement stmt = connection.createStatement();
 
46
        stmt.execute("drop table if exists t2");
 
47
        stmt.execute("drop table if exists t1");
 
48
        stmt.execute("CREATE TABLE t1 ( id1 integer, constraint pk primary key(id1))");
 
49
        stmt.execute("CREATE TABLE t2 (id2a integer, id2b integer, constraint pk primary key(id2a, id2b), constraint fk1 foreign key(id2a) references t1(id1),  constraint fk2 foreign key(id2b) references t1(id1))");
 
50
 
 
51
        DatabaseMetaData dbmd = connection.getMetaData();
 
52
        ResultSet rs = dbmd.getPrimaryKeys("test",null,"t2");
 
53
        int i=0;
 
54
        while(rs.next()) {
 
55
            i++;
 
56
            assertEquals("test",rs.getString("table_cat"));
 
57
            assertEquals(null,rs.getString("table_schem"));
 
58
            assertEquals("t2",rs.getString("table_name"));
 
59
            assertEquals(i,rs.getShort("key_seq"));
 
60
        }
 
61
        assertEquals(2,i);
 
62
    }
42
63
    @Test
43
64
    public void datetimeTest() throws SQLException {
44
65
        Statement stmt = connection.createStatement();