use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.
the class Oracle2PG_DataTypeTest_number_int method test_oracle2pg_int_13.
public void test_oracle2pg_int_13() throws Exception {
String sql = "number(13, 0)";
SQLDataType dataType = SQLParserUtils.createExprParser(sql, JdbcConstants.ORACLE).parseDataType();
SQLDataType pgDataType = SQLTransformUtils.transformOracleToPostgresql(dataType);
assertEquals("BIGINT", pgDataType.toString());
}
use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.
the class Oracle2PG_DataTypeTest_number_int method test_oracle2pg_int_4.
public void test_oracle2pg_int_4() throws Exception {
String sql = "number(4, 0)";
SQLDataType dataType = SQLParserUtils.createExprParser(sql, JdbcConstants.ORACLE).parseDataType();
SQLDataType pgDataType = SQLTransformUtils.transformOracleToPostgresql(dataType);
assertEquals("SMALLINT", pgDataType.toString());
}
use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.
the class Oracle2PG_DataTypeTest_number_int method test_oracle2pg_int_21.
public void test_oracle2pg_int_21() throws Exception {
String sql = "number(21, 0)";
SQLDataType dataType = SQLParserUtils.createExprParser(sql, JdbcConstants.ORACLE).parseDataType();
SQLDataType pgDataType = SQLTransformUtils.transformOracleToPostgresql(dataType);
assertEquals("DECIMAL(21)", pgDataType.toString());
}
use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.
the class Oracle2PG_DataTypeTest_number_int method test_oracle2pg_int_20_x.
public void test_oracle2pg_int_20_x() throws Exception {
String sql = "number(20)";
SQLDataType dataType = SQLParserUtils.createExprParser(sql, JdbcConstants.ORACLE).parseDataType();
SQLDataType pgDataType = SQLTransformUtils.transformOracleToPostgresql(dataType);
assertEquals("BIGINT", pgDataType.toString());
}
use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.
the class DB2StatementParser method parseAlterColumn.
protected SQLAlterTableAlterColumn parseAlterColumn() {
if (lexer.token() == Token.COLUMN) {
lexer.nextToken();
}
SQLColumnDefinition column = this.exprParser.parseColumn();
SQLAlterTableAlterColumn alterColumn = new SQLAlterTableAlterColumn();
alterColumn.setColumn(column);
if (column.getDataType() == null && column.getConstraints().size() == 0) {
if (lexer.token() == Token.SET) {
lexer.nextToken();
if (lexer.token() == Token.NOT) {
lexer.nextToken();
accept(Token.NULL);
alterColumn.setSetNotNull(true);
} else if (lexer.token() == Token.DEFAULT) {
lexer.nextToken();
SQLExpr defaultValue = this.exprParser.expr();
alterColumn.setSetDefault(defaultValue);
} else if (lexer.identifierEquals(FnvHash.Constants.DATA)) {
lexer.nextToken();
acceptIdentifier("TYPE");
SQLDataType dataType = this.exprParser.parseDataType();
alterColumn.setDataType(dataType);
} else {
throw new ParserException("TODO : " + lexer.info());
}
} else if (lexer.token() == Token.DROP) {
lexer.nextToken();
if (lexer.token() == Token.NOT) {
lexer.nextToken();
accept(Token.NULL);
alterColumn.setDropNotNull(true);
} else {
accept(Token.DEFAULT);
alterColumn.setDropDefault(true);
}
}
}
return alterColumn;
}
Aggregations