Package com.alibaba.druid.sql.dialect.mysql.parser

Examples of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser


    return SQLParserUtils.createSQLStatementParser(sql, dbType);
  }

  public static SQLExprParser createExprParser(String sql, String dbType) {
    if (WASP.equals(dbType) || JdbcUtils.HBASE.equals(dbType)) {
      return new MySqlExprParser(sql);
    }
    return SQLParserUtils.createExprParser(sql, dbType);
  }
View Full Code Here


    public static SQLExpr toMySqlExpr(String sql) {
        MySqlLexer lexer = new MySqlLexer(sql);
        lexer.nextToken();

        MySqlExprParser parser = new MySqlExprParser(lexer);
        SQLExpr expr = parser.expr();

        if (lexer.token() != Token.EOF) {
            throw new ParserException("illegal sql expr : " + sql);
        }
View Full Code Here

        if (JdbcUtils.ORACLE.equals(dbType)) {
            return new OracleExprParser(sql);
        }

        if (JdbcUtils.MYSQL.equals(dbType)) {
            return new MySqlExprParser(sql);
        }

        if (JdbcUtils.POSTGRESQL.equals(dbType)) {
            return new PGExprParser(sql);
        }
View Full Code Here

        }

        if (JdbcUtils.MYSQL.equals(dbType) || //
            JdbcUtils.MARIADB.equals(dbType) || //
            JdbcUtils.H2.equals(dbType)) {
            return new MySqlExprParser(sql);
        }

        if (JdbcUtils.POSTGRESQL.equals(dbType)) {
            return new PGExprParser(sql);
        }
View Full Code Here

    public void test_exits() throws Exception {
        String sql = "-a";
        String sql_c = "-(a+1 + +(b+1))";
        SQLUnaryExpr exprA, exprB, exprC;
        {
            MySqlExprParser parser = new MySqlExprParser(sql);
            exprA = (SQLUnaryExpr) parser.expr();
        }
        {
            MySqlExprParser parser = new MySqlExprParser(sql);
            exprB = (SQLUnaryExpr) parser.expr();
        }
        {
            MySqlExprParser parser = new MySqlExprParser(sql_c);
            exprC = (SQLUnaryExpr) parser.expr();
        }
        Assert.assertEquals(exprA, exprB);
        Assert.assertNotEquals(exprA, exprC);
        Assert.assertTrue(exprA.equals(exprA));
        Assert.assertFalse(exprA.equals(new Object()));
View Full Code Here

    public void test_exits() throws Exception {
        String sql = "fstate in (select state from t_status)";
        String sql_c = "fstate_c in (select state from t_status)";
        SQLInSubQueryExpr exprA, exprB, exprC;
        {
            MySqlExprParser parser = new MySqlExprParser(sql);
            exprA = (SQLInSubQueryExpr) parser.expr();
        }
        {
            MySqlExprParser parser = new MySqlExprParser(sql);
            exprB = (SQLInSubQueryExpr) parser.expr();
        }
        {
            MySqlExprParser parser = new MySqlExprParser(sql_c);
            exprC = (SQLInSubQueryExpr) parser.expr();
        }
        Assert.assertEquals(exprA, exprB);
        Assert.assertNotEquals(exprA, exprC);
        Assert.assertTrue(exprA.equals(exprA));
        Assert.assertFalse(exprA.equals(new Object()));
View Full Code Here

* @author <a href="mailto:shuo.qius@alibaba-inc.com">QIU Shuo</a>
*/
public class LiteralHexadecimalTest extends TestCase {
    public void test_0() throws Exception {
        String sql = "x'E982B1E7A195275C73'";
        SQLHexExpr hex = (SQLHexExpr) new MySqlExprParser(sql).expr();
        Assert.assertEquals("邱硕'\\s", new String(hex.toBytes(), "utf-8"));
    }
View Full Code Here

        Assert.assertEquals("邱硕'\\s", new String(hex.toBytes(), "utf-8"));
    }

    public void test_1() throws Exception {
        String sql = "x'0D0A'";
        SQLHexExpr hex = (SQLHexExpr) new MySqlExprParser(sql).expr();
        Assert.assertEquals("\r\n", new String(hex.toBytes(), "utf-8"));
    }
View Full Code Here

        Assert.assertEquals("\r\n", new String(hex.toBytes(), "utf-8"));
    }
   
    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"));
    }
View Full Code Here

        Assert.assertEquals("MySQL", new String(hex.toBytes(), "utf-8"));
    }
   
    public void test_3() throws Exception {
        String sql = "0x5061756c";
        SQLHexExpr hex = (SQLHexExpr) new MySqlExprParser(sql).expr();
        Assert.assertEquals("Paul", new String(hex.toBytes(), "utf-8"));
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.