本文整理汇总了Java中com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock.getWhere方法的典型用法代码示例。如果您正苦于以下问题:Java MySqlSelectQueryBlock.getWhere方法的具体用法?Java MySqlSelectQueryBlock.getWhere怎么用?Java MySqlSelectQueryBlock.getWhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock
的用法示例。
在下文中一共展示了MySqlSelectQueryBlock.getWhere方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isConditionAlwaysTrue
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
private boolean isConditionAlwaysTrue(SQLStatement statement) {
SQLSelectStatement selectStmt = (SQLSelectStatement)statement;
SQLSelectQuery sqlSelectQuery = selectStmt.getSelect().getQuery();
if(sqlSelectQuery instanceof MySqlSelectQueryBlock) {
MySqlSelectQueryBlock mysqlSelectQuery = (MySqlSelectQueryBlock)selectStmt.getSelect().getQuery();
SQLExpr expr = mysqlSelectQuery.getWhere();
Object o = WallVisitorUtils.getValue(expr);
if(Boolean.TRUE.equals(o)) {
return true;
}
return false;
} else {//union
return false;
}
}
示例2: isNoSharding
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
public static boolean isNoSharding(ServerConnection source, SQLSelectQuery sqlSelectQuery, SQLStatement selectStmt, String contextSchema, StringPtr sqlSchema)
throws SQLException {
if (sqlSelectQuery instanceof MySqlSelectQueryBlock) {
MySqlSelectQueryBlock mySqlSelectQueryBlock = (MySqlSelectQueryBlock) sqlSelectQuery;
if (!isNoSharding(source, mySqlSelectQueryBlock.getFrom(), selectStmt, contextSchema, sqlSchema)) {
return false;
}
if (mySqlSelectQueryBlock.getWhere() != null && !SchemaUtil.isNoSharding(source, mySqlSelectQueryBlock.getWhere(), contextSchema, sqlSchema)) {
return false;
}
for (SQLSelectItem selectItem : mySqlSelectQueryBlock.getSelectList()) {
if (!SchemaUtil.isNoSharding(source, selectItem.getExpr(), contextSchema, sqlSchema)) {
return false;
}
}
return true;
} else if (sqlSelectQuery instanceof MySqlUnionQuery) {
return isNoSharding(source, (MySqlUnionQuery) sqlSelectQuery, selectStmt, contextSchema, sqlSchema);
} else {
return false;
}
}
示例3: testWhere
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
@Test
public void testWhere() {
MySqlSelectQueryBlock query = getQuery("select col1,col2 from table1 where a =1 ");
SQLExpr expr = query.getWhere();
MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset,null);
expr.accept(v);
Item item = v.getItem();
Assert.assertEquals(true, "a = 1".equals(item.getItemName()));
}
示例4: visit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
public boolean visit(MySqlSelectQueryBlock x) {
if (x.getOrderBy() != null) {
x.getOrderBy().setParent(x);
}
print0(ucase ? "SELECT COUNT(*) " : "select count(*) ");
if (x.getFrom() != null) {
println();
print0(ucase ? "FROM " : "from ");
x.getFrom().accept(this);
}
if (x.getWhere() != null) {
println();
print0(ucase ? "WHERE " : "where ");
x.getWhere().setParent(x);
x.getWhere().accept(this);
}
if (x.getGroupBy() != null) {
println();
x.getGroupBy().accept(this);
}
if (x.getOrderBy() != null) {
println();
x.getOrderBy().accept(this);
}
return false;
}
示例5: getWhere
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
private static SQLExpr getWhere(SQLParsedResult parseResult) {
SQLExpr expr = null;
SQLStatement stmt = parseResult.getStmt();
if (parseResult.getType() == SqlType.SELECT) {
MySqlSelectQueryBlock query = (MySqlSelectQueryBlock) (((SQLSelectStatement) stmt).getSelect()).getQuery();
expr = query.getWhere();
} else if (parseResult.getType() == SqlType.UPDATE) {
expr = ((MySqlUpdateStatement) stmt).getWhere();
} else if (parseResult.getType() == SqlType.DELETE) {
expr = ((MySqlDeleteStatement) stmt).getWhere();
}
return expr;
}
示例6: WhereParser
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
public WhereParser(SqlParser sqlParser, MySqlSelectQueryBlock query) {
this.sqlParser = sqlParser;
this.query = query;
this.where = query.getWhere();
}
示例7: visit
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock; //导入方法依赖的package包/类
public boolean visit(MySqlSelectQueryBlock sqlSelectQuery) {
SQLTableSource from = sqlSelectQuery.getFrom();
if (from != null) {
visit(from);
if (this.tableNode instanceof NoNameNode) {
this.tableNode.setSql(SQLUtils.toMySqlString(sqlSelectQuery));
}
} else {
this.tableNode = new NoNameNode(currentDb, SQLUtils.toMySqlString(sqlSelectQuery));
}
if (tableNode != null && (sqlSelectQuery.getDistionOption() == SQLSetQuantifier.DISTINCT || sqlSelectQuery.getDistionOption() == SQLSetQuantifier.DISTINCTROW)) {
this.tableNode.setDistinct(true);
}
List<SQLSelectItem> items = sqlSelectQuery.getSelectList();
if (items != null) {
List<Item> selectItems = handleSelectItems(items);
if (selectItems != null) {
this.tableNode.select(selectItems);
}
}
SQLExpr whereExpr = sqlSelectQuery.getWhere();
if (whereExpr != null) {
handleWhereCondition(whereExpr);
}
SQLOrderBy orderBy = sqlSelectQuery.getOrderBy();
if (orderBy != null) {
handleOrderBy(orderBy);
}
SQLSelectGroupByClause groupBy = sqlSelectQuery.getGroupBy();
if (groupBy != null) {
handleGroupBy(groupBy);
}
SQLLimit limit = sqlSelectQuery.getLimit();
if (limit != null) {
handleLimit(limit);
}
return true;
}