@Test public void testParseCreateTableInlinePrimaryKeyWithOrder() throws Exception { for (String order : new String[] {"asc", "desc"}) { String s = "create table core.entity_history_archive (id char(15) primary key ${o})" .replace("${o}", order); CreateTableStatement stmt = (CreateTableStatement) new SQLParser(new StringReader(s)).parseStatement(); List<ColumnDef> columnDefs = stmt.getColumnDefs(); assertEquals(1, columnDefs.size()); assertEquals(SortOrder.fromDDLValue(order), columnDefs.iterator().next().getSortOrder()); } }
@Test public void testParseCreateTablePrimaryKeyConstraintWithOrder() throws Exception { for (String order : new String[] {"asc", "desc"}) { String s = "create table core.entity_history_archive (id CHAR(15), name VARCHAR(150), constraint pk primary key (id ${o}, name ${o}))" .replace("${o}", order); CreateTableStatement stmt = (CreateTableStatement) new SQLParser(new StringReader(s)).parseStatement(); PrimaryKeyConstraint pkConstraint = stmt.getPrimaryKeyConstraint(); List<Pair<ColumnName, SortOrder>> columns = pkConstraint.getColumnNames(); assertEquals(2, columns.size()); for (Pair<ColumnName, SortOrder> pair : columns) { assertEquals( SortOrder.fromDDLValue(order), pkConstraint.getColumn(pair.getFirst()).getSecond()); } } }