use of net.sf.jsqlparser.statement.alter.AlterExpression.ColumnDataType in project JSqlParser by JSQLParser.
the class AlterTest method testAlterTableAddColumn4.
public void testAlterTableAddColumn4() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("ALTER TABLE mytable ADD COLUMN col1 varchar (255), ADD COLUMN col2 integer");
Statement stmt = CCJSqlParserUtil.parse("ALTER TABLE mytable ADD COLUMN col1 varchar (255), ADD COLUMN col2 integer");
Alter alter = (Alter) stmt;
List<AlterExpression> alterExps = alter.getAlterExpressions();
AlterExpression col1Exp = alterExps.get(0);
AlterExpression col2Exp = alterExps.get(1);
List<ColumnDataType> col1DataTypes = col1Exp.getColDataTypeList();
List<ColumnDataType> col2DataTypes = col2Exp.getColDataTypeList();
assertEquals("col1", col1DataTypes.get(0).getColumnName());
assertEquals("col2", col2DataTypes.get(0).getColumnName());
assertEquals("varchar (255)", col1DataTypes.get(0).getColDataType().toString());
assertEquals("integer", col2DataTypes.get(0).getColDataType().toString());
}
use of net.sf.jsqlparser.statement.alter.AlterExpression.ColumnDataType in project JSqlParser by JSQLParser.
the class AlterTest method testAlterTableAddColumnWithZone.
public void testAlterTableAddColumnWithZone() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("ALTER TABLE mytable ADD COLUMN col1 timestamp with time zone");
assertSqlCanBeParsedAndDeparsed("ALTER TABLE mytable ADD COLUMN col1 timestamp without time zone");
assertSqlCanBeParsedAndDeparsed("ALTER TABLE mytable ADD COLUMN col1 date with time zone");
assertSqlCanBeParsedAndDeparsed("ALTER TABLE mytable ADD COLUMN col1 date without time zone");
Statement stmt = CCJSqlParserUtil.parse("ALTER TABLE mytable ADD COLUMN col1 timestamp with time zone");
Alter alter = (Alter) stmt;
List<AlterExpression> alterExps = alter.getAlterExpressions();
AlterExpression col1Exp = alterExps.get(0);
List<ColumnDataType> col1DataTypes = col1Exp.getColDataTypeList();
assertEquals("timestamp with time zone", col1DataTypes.get(0).getColDataType().toString());
}
use of net.sf.jsqlparser.statement.alter.AlterExpression.ColumnDataType in project JSqlParser by JSQLParser.
the class AlterTest method testAlterTableAddColumn.
public void testAlterTableAddColumn() throws JSQLParserException {
Statement stmt = CCJSqlParserUtil.parse("ALTER TABLE mytable ADD COLUMN 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.ColumnDataType in project JSqlParser by JSQLParser.
the class AlterTest method testAlterTableAddColumn5.
public void testAlterTableAddColumn5() throws JSQLParserException {
Statement stmt = CCJSqlParserUtil.parse("ALTER TABLE mytable ADD col1 timestamp (3)");
// COLUMN keyword appears in deparsed statement
assertStatementCanBeDeparsedAs(stmt, "ALTER TABLE mytable ADD COLUMN col1 timestamp (3)");
Alter alter = (Alter) stmt;
List<AlterExpression> alterExps = alter.getAlterExpressions();
AlterExpression col1Exp = alterExps.get(0);
List<ColumnDataType> col1DataTypes = col1Exp.getColDataTypeList();
assertEquals("col1", col1DataTypes.get(0).getColumnName());
assertEquals("timestamp (3)", col1DataTypes.get(0).getColDataType().toString());
}
use of net.sf.jsqlparser.statement.alter.AlterExpression.ColumnDataType 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());
}
Aggregations