Search in sources :

Example 6 with SQLHexExpr

use of com.alibaba.druid.sql.ast.expr.SQLHexExpr in project druid by alibaba.

the class LiteralHexadecimalTest method test_2.

public void test_2() throws Exception {
    String sql = "X'4D7953514C'";
    SQLHexExpr hex = (SQLHexExpr) new MySqlExprParser(sql).expr();
    Assert.assertEquals("MySQL", new String(hex.toBytes(), "utf-8"));
}
Also used : SQLHexExpr(com.alibaba.druid.sql.ast.expr.SQLHexExpr) MySqlExprParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser)

Example 7 with SQLHexExpr

use of com.alibaba.druid.sql.ast.expr.SQLHexExpr in project druid by alibaba.

the class LiteralHexadecimalTest method test_5.

public void test_5() throws Exception {
    String sql = "0x636174";
    SQLHexExpr hex = (SQLHexExpr) new MySqlExprParser(sql).expr();
    Assert.assertEquals("cat", new String(hex.toBytes(), "utf-8"));
}
Also used : SQLHexExpr(com.alibaba.druid.sql.ast.expr.SQLHexExpr) MySqlExprParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser)

Aggregations

SQLHexExpr (com.alibaba.druid.sql.ast.expr.SQLHexExpr)7 MySqlExprParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser)6 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)1 SQLBinaryExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryExpr)1 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)1 SQLCharExpr (com.alibaba.druid.sql.ast.expr.SQLCharExpr)1 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)1 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)1 SQLMethodInvokeExpr (com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr)1 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)1 MySqlCharExpr (com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr)1 MySqlExtractExpr (com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlExtractExpr)1 MySqlIntervalUnit (com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlIntervalUnit)1 MySqlMatchAgainstExpr (com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlMatchAgainstExpr)1 MySqlUserName (com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlUserName)1 ParserException (com.alibaba.druid.sql.parser.ParserException)1