use of org.datanucleus.store.query.expression.SubqueryExpression in project datanucleus-rdbms by datanucleus.
the class QueryToSQLMapper method processSubqueryExpression.
/* (non-Javadoc)
* @see org.datanucleus.query.evaluator.AbstractExpressionEvaluator#processSubqueryExpression(org.datanucleus.query.expression.SubqueryExpression)
*/
@Override
protected Object processSubqueryExpression(SubqueryExpression expr) {
String keyword = expr.getKeyword();
Expression subqueryExpr = expr.getRight();
if (subqueryExpr instanceof VariableExpression) {
processVariableExpression((VariableExpression) subqueryExpr);
SQLExpression subquerySqlExpr = stack.pop();
if (keyword.equals("EXISTS")) {
// EXISTS expressions need to be Boolean
if (subquerySqlExpr instanceof org.datanucleus.store.rdbms.sql.expression.SubqueryExpression) {
SQLStatement subStmt = ((org.datanucleus.store.rdbms.sql.expression.SubqueryExpression) subquerySqlExpr).getSubqueryStatement();
subquerySqlExpr = new BooleanSubqueryExpression(stmt, keyword, subStmt);
} else {
SQLStatement subStmt = ((SubqueryExpressionComponent) subquerySqlExpr).getSubqueryStatement();
subquerySqlExpr = new BooleanSubqueryExpression(stmt, keyword, subStmt);
}
} else if (subquerySqlExpr instanceof org.datanucleus.store.rdbms.sql.expression.SubqueryExpression) {
SQLStatement subStmt = ((org.datanucleus.store.rdbms.sql.expression.SubqueryExpression) subquerySqlExpr).getSubqueryStatement();
subquerySqlExpr = new BooleanSubqueryExpression(stmt, keyword, subStmt);
} else if (subquerySqlExpr instanceof NumericSubqueryExpression) {
if ((keyword.equalsIgnoreCase("SOME") || keyword.equalsIgnoreCase("ALL") || keyword.equalsIgnoreCase("ANY")) && !storeMgr.getDatastoreAdapter().supportsOption(DatastoreAdapter.SOME_ANY_ALL_SUBQUERY_EXPRESSIONS)) {
throw new NucleusException("'SOME|ALL|ANY{subquery}' is not supported by this datastore");
}
// Apply keyword (e.g ALL, SOME, ANY) to numeric expressions
((NumericSubqueryExpression) subquerySqlExpr).setKeyword(keyword);
}
stack.push(subquerySqlExpr);
return subquerySqlExpr;
}
throw new NucleusException("Dont currently support SubqueryExpression " + keyword + " for type " + subqueryExpr);
}
Aggregations