use of net.sf.jsqlparser.statement.alter.AlterExpression in project JSqlParser by JSQLParser.
the class AlterTest method testAlterTableAddColumn_ColumnKeyWordImplicit.
public void testAlterTableAddColumn_ColumnKeyWordImplicit() throws JSQLParserException {
Statement stmt = CCJSqlParserUtil.parse("ALTER TABLE mytable ADD mycolumn varchar (255)");
assertTrue(stmt instanceof Alter);
Alter alter = (Alter) stmt;
assertEquals("mytable", alter.getTable().getFullyQualifiedName());
AlterExpression alterExp = alter.getAlterExpressions().get(0);
assertNotNull(alterExp);
List<ColumnDataType> colDataTypes = alterExp.getColDataTypeList();
assertEquals("mycolumn", colDataTypes.get(0).getColumnName());
assertEquals("varchar (255)", colDataTypes.get(0).getColDataType().toString());
}
use of net.sf.jsqlparser.statement.alter.AlterExpression in project JSqlParser by JSQLParser.
the class AlterTest method testAlterTablePK.
public void testAlterTablePK() throws JSQLParserException {
final String sql = "ALTER TABLE `Author` ADD CONSTRAINT `AuthorPK` PRIMARY KEY (`ID`)";
Statement stmt = CCJSqlParserUtil.parse(sql);
assertStatementCanBeDeparsedAs(stmt, sql);
AlterExpression alterExpression = ((Alter) stmt).getAlterExpressions().get(0);
assertNull(alterExpression.getConstraintName());
// TODO: should this pass? ==> assertEquals(alterExpression.getPkColumns().get(0), "ID");
assertEquals(alterExpression.getIndex().getColumnsNames().get(0), "`ID`");
}
Aggregations