use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.
the class ItemDatetimeTypecast method toExpression.
@Override
public SQLExpr toExpression() {
SQLCastExpr cast = new SQLCastExpr();
cast.setExpr(args.get(0).toExpression());
SQLDataTypeImpl dataType = new SQLDataTypeImpl("DATETIME");
if (decimals != Item.NOT_FIXED_DEC) {
dataType.addArgument(new SQLIntegerExpr(decimals));
}
cast.setDataType(dataType);
return cast;
}
use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.
the class ItemFuncSigned method toExpression.
@Override
public SQLExpr toExpression() {
SQLCastExpr cast = new SQLCastExpr();
cast.setExpr(args.get(0).toExpression());
SQLDataTypeImpl dataType = new SQLDataTypeImpl("SIGNED");
cast.setDataType(dataType);
return cast;
}
use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.
the class ItemFuncUnsigned method toExpression.
@Override
public SQLExpr toExpression() {
SQLCastExpr cast = new SQLCastExpr();
cast.setExpr(args.get(0).toExpression());
SQLDataTypeImpl dataType = new SQLDataTypeImpl("UNSIGNED");
cast.setDataType(dataType);
return cast;
}
use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project dble by actiontech.
the class ItemDateTypecast method toExpression.
@Override
public SQLExpr toExpression() {
SQLCastExpr cast = new SQLCastExpr();
cast.setExpr(args.get(0).toExpression());
SQLDataTypeImpl dataType = new SQLDataTypeImpl("DATE");
cast.setDataType(dataType);
return cast;
}
use of com.alibaba.druid.sql.ast.expr.SQLCastExpr in project druid by alibaba.
the class EqualTest_cast method test_exits.
public void test_exits() throws Exception {
String sql = "cast(a as varchar(50))";
String sql_c = "cast(b as varchar(50))";
SQLCastExpr exprA, exprB, exprC;
{
OracleExprParser parser = new OracleExprParser(sql);
exprA = (SQLCastExpr) parser.expr();
}
{
OracleExprParser parser = new OracleExprParser(sql);
exprB = (SQLCastExpr) parser.expr();
}
{
OracleExprParser parser = new OracleExprParser(sql_c);
exprC = (SQLCastExpr) parser.expr();
}
Assert.assertEquals(exprA, exprB);
Assert.assertNotEquals(exprA, exprC);
Assert.assertTrue(exprA.equals(exprA));
Assert.assertFalse(exprA.equals(new Object()));
Assert.assertEquals(exprA.hashCode(), exprB.hashCode());
Assert.assertEquals(new SQLCastExpr(), new SQLCastExpr());
Assert.assertEquals(new SQLCastExpr().hashCode(), new SQLCastExpr().hashCode());
Assert.assertEquals(new SQLDataTypeImpl(), new SQLDataTypeImpl());
Assert.assertEquals(new SQLDataTypeImpl().hashCode(), new SQLDataTypeImpl().hashCode());
}
Aggregations