MCPcopy Create free account
hub / github.com/Nemo1870/sql-parse / getWhere

Method getWhere

src/main/java/com/sql/parse/util/SqlParser.java:237–272  ·  view source on GitHub ↗

@title: getWhere @desc 获取where条件

()

Source from the content-addressed store, hash-verified

235 * @desc 获取where条件
236 */
237 public String getWhere() {
238 switch (SqlParseConfig.getHandle()) {
239 case "com.github.jsqlparser":{
240 if ("SELECT".equals(type)) {
241 Select select = (Select) statement;
242 PlainSelect plainSelect = (PlainSelect)select.getSelect().getSelectBody();
243 return plainSelect.getWhere().toString();
244 } else if ("UPDATE".equals(type)) {
245 Update update = (Update) statement;
246 return update.getUpdate().getWhere().toString();
247 } else if ("DELETE".equals(type)) {
248 Delete delete = (Delete) statement;
249 return delete.getDelete().getWhere().toString();
250 } else {
251 throw BaseException.errorCode(SqlParseConstant.CODE_011);
252 }
253 }
254 case "com.alibaba.druid":{
255 if ("SELECT".equals(type)) {
256 com.sql.parse.statement.impl.druid.Select select = (com.sql.parse.statement.impl.druid.Select) statement;
257 return select.getSelect().getSelect().getQueryBlock().getWhere().toString();
258 } else if ("UPDATE".equals(type)) {
259 com.sql.parse.statement.impl.druid.Update update = (com.sql.parse.statement.impl.druid.Update) statement;
260 return update.getUpdate().getWhere().toString();
261 } else if ("DELETE".equals(type)) {
262 com.sql.parse.statement.impl.druid.Delete delete = (com.sql.parse.statement.impl.druid.Delete) statement;
263 return delete.getDelete().getWhere().toString();
264 } else {
265 throw BaseException.errorCode(SqlParseConstant.CODE_011);
266 }
267 }
268 default:{
269 throw BaseException.errorCode(SqlParseConstant.CODE_018);
270 }
271 }
272 }
273
274 /**
275 * @title: getAliasOrColumnNames

Callers 15

getSqlMethod · 0.80
whereMethod · 0.80
andMethod · 0.80
orMethod · 0.80
asInterceptorMethod · 0.80
argInterceptorMethod · 0.80
expressionInterceptorMethod · 0.80
columnInterceptorMethod · 0.80
ownerInterceptorMethod · 0.80
getSqlMethod · 0.80
whereMethod · 0.80

Calls 5

getHandleMethod · 0.95
getSelectMethod · 0.95
getUpdateMethod · 0.95
getDeleteMethod · 0.95
errorCodeMethod · 0.95

Tested by 1