Search in sources :

Example 51 with SQLExpr

use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.

the class SQLSelectBuilderImpl method selectWithAlias.

@Override
public SQLSelectBuilderImpl selectWithAlias(String column, String alias) {
    SQLSelectQueryBlock queryBlock = getQueryBlock();
    SQLExpr columnExpr = SQLUtils.toSQLExpr(column, dbType);
    SQLSelectItem selectItem = new SQLSelectItem(columnExpr, alias);
    queryBlock.addSelectItem(selectItem);
    return this;
}
Also used : SQLSelectItem(com.alibaba.druid.sql.ast.statement.SQLSelectItem) SQLSelectQueryBlock(com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Example 52 with SQLExpr

use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.

the class SQLUpdateBuilderImpl method where.

@Override
public SQLUpdateBuilderImpl where(String expr) {
    SQLUpdateStatement update = getSQLUpdateStatement();
    SQLExpr exprObj = SQLUtils.toSQLExpr(expr, dbType);
    update.setWhere(exprObj);
    return this;
}
Also used : SQLUpdateStatement(com.alibaba.druid.sql.ast.statement.SQLUpdateStatement) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Example 53 with SQLExpr

use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.

the class SQLUpdateBuilderImpl method setValue.

public SQLUpdateBuilderImpl setValue(String column, Object value) {
    SQLUpdateStatement update = getSQLUpdateStatement();
    SQLExpr columnExpr = SQLUtils.toSQLExpr(column, dbType);
    SQLExpr valueExpr = toSQLExpr(value, dbType);
    SQLUpdateSetItem item = new SQLUpdateSetItem();
    item.setColumn(columnExpr);
    item.setValue(valueExpr);
    update.addItem(item);
    return this;
}
Also used : SQLUpdateSetItem(com.alibaba.druid.sql.ast.statement.SQLUpdateSetItem) SQLUpdateStatement(com.alibaba.druid.sql.ast.statement.SQLUpdateStatement) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Example 54 with SQLExpr

use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.

the class SQLUpdateBuilderImpl method whereAnd.

@Override
public SQLUpdateBuilderImpl whereAnd(String expr) {
    SQLUpdateStatement update = getSQLUpdateStatement();
    SQLExpr exprObj = SQLUtils.toSQLExpr(expr, dbType);
    SQLExpr newCondition = SQLUtils.buildCondition(SQLBinaryOperator.BooleanAnd, exprObj, false, update.getWhere());
    update.setWhere(newCondition);
    return this;
}
Also used : SQLUpdateStatement(com.alibaba.druid.sql.ast.statement.SQLUpdateStatement) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Example 55 with SQLExpr

use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.

the class OracleSelectParser method parseInto.

protected void parseInto(OracleSelectQueryBlock x) {
    if (lexer.token() == Token.INTO) {
        lexer.nextToken();
        SQLExpr expr = expr();
        if (lexer.token() != Token.COMMA) {
            x.setInto(expr);
            return;
        }
        SQLListExpr list = new SQLListExpr();
        list.addItem(expr);
        while (lexer.token() == Token.COMMA) {
            lexer.nextToken();
            list.addItem(expr());
        }
        x.setInto(list);
    }
}
Also used : SQLListExpr(com.alibaba.druid.sql.ast.expr.SQLListExpr) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Aggregations

SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)225 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)42 SQLName (com.alibaba.druid.sql.ast.SQLName)33 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)30 ParserException (com.alibaba.druid.sql.parser.ParserException)23 SQLObject (com.alibaba.druid.sql.ast.SQLObject)22 SQLPropertyExpr (com.alibaba.druid.sql.ast.expr.SQLPropertyExpr)17 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)16 SQLCharExpr (com.alibaba.druid.sql.ast.expr.SQLCharExpr)13 SQLSelectQueryBlock (com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock)13 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)12 ArrayList (java.util.ArrayList)12 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)11 SQLMethodInvokeExpr (com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr)10 SQLSelectItem (com.alibaba.druid.sql.ast.statement.SQLSelectItem)10 SQLSelectQuery (com.alibaba.druid.sql.ast.statement.SQLSelectQuery)10 SQLOrderBy (com.alibaba.druid.sql.ast.SQLOrderBy)8 MySqlSelectQueryBlock (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock)8 SQLNumberExpr (com.alibaba.druid.sql.ast.expr.SQLNumberExpr)7 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)7