use of lucee.runtime.sql.exp.Expression in project Lucee by lucee.
the class SelectParser method andOp.
private Expression andOp(ParserString raw) throws SQLParserException {
Expression expr = notOp(raw);
while (raw.forwardIfCurrentAndNoWordNumberAfter("and")) {
raw.removeSpace();
expr = new Operation2(expr, notOp(raw), Operation.OPERATION2_AND);
}
return expr;
}
use of lucee.runtime.sql.exp.Expression in project Lucee by lucee.
the class SelectParser method orOp.
private Expression orOp(ParserString raw) throws SQLParserException {
Expression expr = andOp(raw);
while (raw.forwardIfCurrentAndNoWordNumberAfter("or")) {
raw.removeSpace();
expr = new Operation2(expr, andOp(raw), Operation.OPERATION2_OR);
}
return expr;
}
use of lucee.runtime.sql.exp.Expression in project Lucee by lucee.
the class SelectParser method whereExpressions.
private void whereExpressions(ParserString raw, Select select) throws SQLParserException {
raw.removeSpace();
Expression exp = expression(raw);
if (exp == null)
throw new SQLParserException("missing where expression");
if (!(exp instanceof Operation))
throw new SQLParserException("invalid where expression (" + Caster.toClassName(exp) + ")");
select.setWhereExpression((Operation) exp);
raw.removeSpace();
}
use of lucee.runtime.sql.exp.Expression in project Lucee by lucee.
the class SelectParser method orderByExpressions.
private void orderByExpressions(ParserString raw, Selects selects) throws SQLParserException {
Expression exp = null;
do {
raw.removeSpace();
// print.out(raw.getCurrent());
exp = expression(raw);
if (!(exp instanceof Column))
throw new SQLParserException("invalid order by part of query");
Column col = (Column) exp;
raw.removeSpace();
if (raw.forwardIfCurrent("desc"))
col.setDirectionBackward(true);
if (raw.forwardIfCurrent("asc"))
col.setDirectionBackward(false);
selects.addOrderByExpression(col);
raw.removeSpace();
} while (raw.forwardIfCurrent(','));
raw.removeSpace();
}
use of lucee.runtime.sql.exp.Expression in project Lucee by lucee.
the class SelectParser method tableList.
private void tableList(ParserString raw, Select select) throws SQLParserException {
Column column = null;
Expression exp = null;
do {
raw.removeSpace();
exp = column(raw);
if (!(exp instanceof Column))
throw new SQLParserException("invalid table definition");
column = (Column) exp;
raw.removeSpace();
if (raw.forwardIfCurrent("as ")) {
String alias = identifier(raw, new RefBooleanImpl(false));
if (alias == null)
throw new SQLParserException("missing alias in select part");
column.setAlias(alias);
} else {
int start = raw.getPos();
RefBoolean hasBracked = new RefBooleanImpl(false);
// TODO having usw
String alias = identifier(raw, hasBracked);
if (!hasBracked.toBooleanValue()) {
if ("where".equalsIgnoreCase(alias))
raw.setPos(start);
else if ("group".equalsIgnoreCase(alias))
raw.setPos(start);
else if ("having".equalsIgnoreCase(alias))
raw.setPos(start);
else if ("union".equalsIgnoreCase(alias))
raw.setPos(start);
else if ("order".equalsIgnoreCase(alias))
raw.setPos(start);
else if ("limit".equalsIgnoreCase(alias))
raw.setPos(start);
else if (alias != null)
column.setAlias(alias);
} else {
if (alias != null)
column.setAlias(alias);
}
}
select.addFromExpression(column);
raw.removeSpace();
} while (raw.forwardIfCurrent(','));
}
Aggregations