Search in sources :

Example 11 with SQLNumberExpr

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

the class WallVisitorUtils method generateTenantValue.

private static SQLExpr generateTenantValue(WallVisitor visitor, String alias, StatementType statementType, String tableName) {
    SQLExpr value;
    TenantCallBack callBack = visitor.getConfig().getTenantCallBack();
    if (callBack != null) {
        WallProvider.setTenantValue(callBack.getTenantValue(statementType, tableName));
    }
    Object tenantValue = WallProvider.getTenantValue();
    if (tenantValue instanceof Number) {
        value = new SQLNumberExpr((Number) tenantValue);
    } else if (tenantValue instanceof String) {
        value = new SQLCharExpr((String) tenantValue);
    } else {
        throw new IllegalStateException("tenant value not support type " + tenantValue);
    }
    return value;
}
Also used : SQLCharExpr(com.alibaba.druid.sql.ast.expr.SQLCharExpr) TenantCallBack(com.alibaba.druid.wall.WallConfig.TenantCallBack) SQLObject(com.alibaba.druid.sql.ast.SQLObject) SQLNumberExpr(com.alibaba.druid.sql.ast.expr.SQLNumberExpr) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Aggregations

SQLNumberExpr (com.alibaba.druid.sql.ast.expr.SQLNumberExpr)11 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)7 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)6 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)4 SQLSelectItem (com.alibaba.druid.sql.ast.statement.SQLSelectItem)4 SQLAllColumnExpr (com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr)3 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)3 SQLCharExpr (com.alibaba.druid.sql.ast.expr.SQLCharExpr)3 SQLPropertyExpr (com.alibaba.druid.sql.ast.expr.SQLPropertyExpr)3 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)3 SQLSelect (com.alibaba.druid.sql.ast.statement.SQLSelect)3 SQLSelectQuery (com.alibaba.druid.sql.ast.statement.SQLSelectQuery)3 SQLSelectQueryBlock (com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock)3 SQLSubqueryTableSource (com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource)3 SQLOrderBy (com.alibaba.druid.sql.ast.SQLOrderBy)2 SQLOver (com.alibaba.druid.sql.ast.SQLOver)2 SQLAggregateExpr (com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)2 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)1 MockResultSet (com.alibaba.druid.mock.MockResultSet)1 MockResultSetMetaData (com.alibaba.druid.mock.MockResultSetMetaData)1