当前位置: 首页>>代码示例>>Java>>正文


Java SQLExpr类代码示例

本文整理汇总了Java中com.alibaba.druid.sql.ast.SQLExpr的典型用法代码示例。如果您正苦于以下问题:Java SQLExpr类的具体用法?Java SQLExpr怎么用?Java SQLExpr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SQLExpr类属于com.alibaba.druid.sql.ast包,在下文中一共展示了SQLExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getColumn

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
@Override
protected Column getColumn(SQLExpr expr) {
    Map<String, String> aliasMap = getAliasMap();
    if (aliasMap == null) {
        return null;
    }

    if (expr instanceof SQLPropertyExpr) {
        return getColumnByExpr((SQLPropertyExpr) expr, aliasMap);
    }

    if (expr instanceof SQLIdentifierExpr) {
        return getColumnByExpr((SQLIdentifierExpr) expr, aliasMap);
    }

    if (expr instanceof SQLBetweenExpr) {
        return getColumnByExpr((SQLBetweenExpr) expr, aliasMap);
    }
    return null;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:21,代码来源:ServerSchemaStatVisitor.java

示例2: contains

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
public boolean contains(SQLTableSource tableSource, SQLExpr condition) {
    if (right.equals(tableSource)) {
        if (this.condition == condition) {
            return true;
        }

        return this.condition != null && this.condition.equals(condition);
    }

    if (left instanceof SQLJoinTableSource) {
        SQLJoinTableSource joinLeft = (SQLJoinTableSource) left;

        if (tableSource instanceof SQLJoinTableSource) {
            SQLJoinTableSource join = (SQLJoinTableSource) tableSource;

            if (join.right.equals(right) && this.condition.equals(condition) && joinLeft.right.equals(join.left)) {
                return true;
            }
        }

        return joinLeft.contains(tableSource, condition);
    }

    return false;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:26,代码来源:SQLJoinTableSource.java

示例3: eval

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
    if (x.getParameters().size() != 1) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    SQLExpr param0 = x.getParameters().get(0);
    param0.accept(visitor);

    Object param0Value = param0.getAttributes().get(EVAL_VALUE);
    if (param0Value == null) {
        return SQLEvalVisitor.EVAL_ERROR;
    }

    String strValue = param0Value.toString();

    int result = strValue.length();
    return result;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:19,代码来源:Length.java

示例4: stringAndNumberEqualConditionWithoutProperty

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
@Test
public void stringAndNumberEqualConditionWithoutProperty() throws SqlParseException {
    SQLExpr sqlExpr = queryToExpr("select * from xxx/locs where 'a' = 1");
    Select select = parser.parseSelect((SQLQueryExpr) sqlExpr);
    List<Where> wheres = select.getWhere().getWheres();
    Assert.assertTrue(wheres.size() == 1);
    Condition condition = (Condition) wheres.get(0);
    Assert.assertTrue(condition.getValue() instanceof ScriptFilter);
    ScriptFilter sf = (ScriptFilter) condition.getValue();
    Assert.assertEquals(sf.getScript(), "'a' == 1");
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:12,代码来源:SqlParserTests.java

示例5: toExpression

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
@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;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:12,代码来源:ItemDatetimeTypecast.java

示例6: columnInExpr

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
private static boolean columnInExpr(SQLExpr sqlExpr, String colName) throws SQLNonTransientException {
    String column;
    if (sqlExpr instanceof SQLIdentifierExpr) {
        column = StringUtil.removeBackQuote(((SQLIdentifierExpr) sqlExpr).getName()).toUpperCase();
    } else if (sqlExpr instanceof SQLPropertyExpr) {
        column = StringUtil.removeBackQuote(((SQLPropertyExpr) sqlExpr).getName()).toUpperCase();
    } else {
        throw new SQLNonTransientException("Unhandled SQL AST node type encountered: " + sqlExpr.getClass());
    }

    return column.equals(colName.toUpperCase());
}
 
开发者ID:actiontech,项目名称:dble,代码行数:13,代码来源:DruidUpdateParser.java

示例7: isMycatSeq

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
private static boolean isMycatSeq(String stmt, SchemaConfig schema)
  {
      if(pattern.matcher(stmt).find()) {
	return true;
}
      SQLStatementParser parser =new MySqlStatementParser(stmt);
      MySqlInsertStatement statement = (MySqlInsertStatement) parser.parseStatement();
      String tableName=   statement.getTableName().getSimpleName();
      TableConfig tableConfig= schema.getTables().get(tableName.toUpperCase());
      if(tableConfig==null) {
	return false;
}
      if(tableConfig.isAutoIncrement())
      {
          boolean isHasIdInSql=false;
          String primaryKey = tableConfig.getPrimaryKey();
          List<SQLExpr> columns = statement.getColumns();
          for (SQLExpr column : columns)
          {
              String columnName = column.toString();
              if(primaryKey.equalsIgnoreCase(columnName))
              {
                  isHasIdInSql = true;
                  break;
              }
          }
          if(!isHasIdInSql) {
		return true;
	}
      }


      return false;
  }
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:35,代码来源:ExplainHandler.java

示例8: toExpression

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
@Override
public SQLExpr toExpression() {
    Item arg0 = args.get(0);
    SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
    aggregate.addArgument(arg0.toExpression());
    if (hasWithDistinct()) {
        aggregate.setOption(SQLAggregateOption.DISTINCT);
    }
    return aggregate;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:ItemSumAvg.java

示例9: setExpr

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
public void setExpr(SQLExpr expr) {
    if (expr != null) {
        expr.setParent(this);
    }
    
    this.expr = expr;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:8,代码来源:SQLInListExpr.java

示例10: isLogicalExpression

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
private static boolean isLogicalExpression(SQLExpr expr) { //XOR?
    if (!(expr instanceof SQLBinaryOpExpr)) {
        return false;
    }
    SQLBinaryOpExpr binOpExpr = (SQLBinaryOpExpr) expr;
    return binOpExpr.getOperator() == SQLBinaryOperator.BooleanAnd || binOpExpr.getOperator() == SQLBinaryOperator.BooleanOr;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:8,代码来源:ExpressionUtil.java

示例11: unwrap

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
public static SQLExpr unwrap(SQLExpr expr) {
    if (expr == null) {
        return null;
    }

    if (expr instanceof SQLQueryExpr) {
        SQLSelect select = ((SQLQueryExpr) expr).getSubQuery();
        if (select == null) {
            return null;
        }
        if (select.getQuery() instanceof SQLSelectQueryBlock) {
            SQLSelectQueryBlock queryBlock = (SQLSelectQueryBlock) select.getQuery();
            if (queryBlock.getFrom() == null) {
                if (queryBlock.getSelectList().size() == 1) {
                    return queryBlock.getSelectList().get(0).getExpr();
                }
            }
        }
    }

    return expr;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:23,代码来源:SQLEvalVisitorUtils.java

示例12: having

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
@Override
public SQLSelectBuilderImpl having(String expr) {
    SQLSelectQueryBlock queryBlock = getQueryBlock();

    SQLSelectGroupByClause groupBy = queryBlock.getGroupBy();
    if (groupBy == null) {
        groupBy = createGroupBy();
        queryBlock.setGroupBy(groupBy);
    }

    SQLExpr exprObj = SQLUtils.toSQLExpr(expr, dbType);
    groupBy.setHaving(exprObj);

    return this;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:16,代码来源:SQLSelectBuilderImpl.java

示例13: parseAlterColumn

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
protected SQLAlterTableAlterColumn parseAlterColumn() {
    if (lexer.token() == Token.COLUMN) {
        lexer.nextToken();
    }

    SQLColumnDefinition column = this.exprParser.parseColumn();

    SQLAlterTableAlterColumn alterColumn = new SQLAlterTableAlterColumn();
    alterColumn.setColumn(column);

    if (column.getDataType() == null && column.getConstraints().size() == 0) {
        if (lexer.token() == Token.SET) {
            lexer.nextToken();
            if (lexer.token() == Token.NOT) {
                lexer.nextToken();
                accept(Token.NULL);
                alterColumn.setSetNotNull(true);
            } else {
                accept(Token.DEFAULT);
                SQLExpr defaultValue = this.exprParser.expr();
                alterColumn.setSetDefault(defaultValue);
            }
        } else if (lexer.token() == Token.DROP) {
            lexer.nextToken();
            if (lexer.token() == Token.NOT) {
                lexer.nextToken();
                accept(Token.NULL);
                alterColumn.setDropNotNull(true);
            } else {
                accept(Token.DEFAULT);
                alterColumn.setDropDefault(true);
            }
        }
    }
    return alterColumn;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:37,代码来源:PGSQLStatementParser.java

示例14: loopFindSubWhereUnit

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
/**
 * 循环寻找子WhereUnit(实际是嵌套的or)
 * @param whereUnitList
 */
private void loopFindSubWhereUnit(List<WhereUnit> whereUnitList) {
	List<WhereUnit> subWhereUnits = new ArrayList<WhereUnit>();
	for(WhereUnit whereUnit : whereUnitList) {
		if(whereUnit.getSplitedExprList().size() > 0) {
			List<SQLExpr> removeSplitedList = new ArrayList<SQLExpr>();
			for(SQLExpr sqlExpr : whereUnit.getSplitedExprList()) {
				reset();
				if(isExprHasOr(sqlExpr)) {
					removeSplitedList.add(sqlExpr);
					WhereUnit subWhereUnit = this.whereUnits.get(0);
					splitUntilNoOr(subWhereUnit);
					whereUnit.addSubWhereUnit(subWhereUnit);
					subWhereUnits.add(subWhereUnit);
				} else {
					this.conditions.clear();
				}
			}
			if(removeSplitedList.size() > 0) {
				whereUnit.getSplitedExprList().removeAll(removeSplitedList);
			}
		}
		subWhereUnits.addAll(whereUnit.getSubWhereUnit());
	}
	if(subWhereUnits.size() > 0) {
		loopFindSubWhereUnit(subWhereUnits);
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:32,代码来源:MycatSchemaStatVisitor.java

示例15: toExpression

import com.alibaba.druid.sql.ast.SQLExpr; //导入依赖的package包/类
@Override
public SQLExpr toExpression() {
    SQLMethodInvokeExpr method = new SQLMethodInvokeExpr(funcName());
    for (Item arg : args) {
        method.addParameter(arg.toExpression());
    }
    return method;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:9,代码来源:ItemSumStd.java


注:本文中的com.alibaba.druid.sql.ast.SQLExpr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。