int cId = createTable("coi", "c", "cid int not null primary key, name varchar(32)");
int oId = createTable("coi", "o", "oid int not null primary key, c_id int, GROUPING FOREIGN KEY (c_id) REFERENCES c(cid)");
createIndex("coi", "o", "__akiban_fk_o", "c_id");
int iId = createTable("coi", "i", "iid int not null primary key, o_id int, idesc varchar(32), GROUPING FOREIGN KEY (o_id) REFERENCES o(oid)");
createIndex("coi", "i", "__akiban_fk_i", "o_id");
AkibanInformationSchema ais = ddl().getAIS(session());
// Lots of checking, the more the merrier
final Table cTable = ais.getTable( ddl().getTableName(session(), cId) );
{
assertEquals("c.columns.size()", 2, cTable.getColumns().size());
assertEquals("c.indexes.size()", 1, cTable.getIndexes().size());
PrimaryKey pk = cTable.getPrimaryKey();
List<Column> expectedPkCols = Arrays.asList( cTable.getColumn("cid") );
assertEquals("pk cols", expectedPkCols, pk.getColumns());
assertSame("pk index", cTable.getIndex("PRIMARY"), pk.getIndex());
assertEquals("pk index cols size", 1, pk.getIndex().getKeyColumns().size());
assertEquals("parent join", null, cTable.getParentJoin());
assertEquals("child joins.size", 1, cTable.getChildJoins().size());
}
final Table oTable = ais.getTable( ddl().getTableName(session(), oId) );
{
assertEquals("c.columns.size()", 2, oTable.getColumns().size());
assertEquals("c.indexes.size()", 2, oTable.getIndexes().size());
PrimaryKey pk = oTable.getPrimaryKey();
List<Column> expectedPkCols = Arrays.asList( oTable.getColumn("oid") );
assertEquals("pk cols", expectedPkCols, pk.getColumns());
assertSame("pk index", oTable.getIndex("PRIMARY"), pk.getIndex());
assertEquals("pk index cols size", 1, pk.getIndex().getKeyColumns().size());
assertNotNull("parent join is null", oTable.getParentJoin());
assertSame("parent join", cTable.getChildJoins().get(0), oTable.getParentJoin());
assertEquals("child joins.size", 1, oTable.getChildJoins().size());
}
final Table iTable = ais.getTable( ddl().getTableName(session(), iId) );
{
assertEquals("c.columns.size()", 3, iTable.getColumns().size());
assertEquals("c.indexes.size()", 2, iTable.getIndexes().size());
PrimaryKey pk = iTable.getPrimaryKey();
List<Column> expectedPkCols = Arrays.asList( iTable.getColumn("iid") );