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


Java MySqlSelectQueryBlock.getWhere方法代码示例

本文整理汇总了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;
	}
	
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:18,代码来源:DruidSelectParser.java

示例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;
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:23,代码来源:SchemaUtil.java

示例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()));
}
 
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:TestMySQLItemVisitor.java

示例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;
}
 
开发者ID:dianping,项目名称:zebra,代码行数:33,代码来源:MysqlCountOutputVisitor.java

示例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;
}
 
开发者ID:dianping,项目名称:zebra,代码行数:16,代码来源:ShardColumnValueUtil.java

示例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();
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:6,代码来源:WhereParser.java

示例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;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:45,代码来源:MySQLPlanNodeVisitor.java


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