/** * Create an array of index columns from a list of columns. The default sort * type is used. * * @param columns the column list * @return the index column array */ public static IndexColumn[] wrap(Column[] columns) { IndexColumn[] list = new IndexColumn[columns.length]; for (int i = 0; i < list.length; i++) { list[i] = new IndexColumn(); list[i].column = columns[i]; } return list; }
private IndexColumn[] parseIndexColumnList() { ArrayList<IndexColumn> columns = New.arrayList(); do { IndexColumn column = new IndexColumn(); column.columnName = readColumnIdentifier(); columns.add(column); if (readIf("ASC")) { // ignore } else if (readIf("DESC")) { column.sortType = SortOrder.DESCENDING; } if (readIf("NULLS")) { if (readIf("FIRST")) { column.sortType |= SortOrder.NULLS_FIRST; } else { read("LAST"); column.sortType |= SortOrder.NULLS_LAST; } } } while (readIf(",")); read(")"); return columns.toArray(new IndexColumn[columns.size()]); }
if (column.isAutoIncrement() && column.isPrimaryKey()) { column.setPrimaryKey(false); IndexColumn[] cols = {new IndexColumn()}; cols[0].columnName = column.getName(); AlterTableAddConstraint pk = new AlterTableAddConstraint( read("KEY"); boolean hash = readIf("HASH"); IndexColumn[] cols = {new IndexColumn()}; cols[0].columnName = column.getName(); AlterTableAddConstraint pk = new AlterTableAddConstraint( unique.setConstraintName(constraintName); unique.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_UNIQUE); IndexColumn[] cols = {new IndexColumn()}; cols[0].columnName = columnName; unique.setIndexColumns(cols); ref.setConstraintName(constraintName); ref.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_REFERENTIAL); IndexColumn[] cols = {new IndexColumn()}; cols[0].columnName = columnName; ref.setIndexColumns(cols);