use of org.apache.cayenne.exp.parser.ASTScalar in project cayenne by apache.
the class SelectQueryReturnTypesIT method testSelectBitwiseOr.
@Test
public void testSelectBitwiseOr() throws Exception {
if (!accessStackAdapter.supportsBitwiseOps()) {
return;
}
createNumericsDataSet();
// to simplify result checking, do double NOT
Expression left = new ASTBitwiseOr(new Object[] { new ASTObjPath(ReturnTypesMap1.INTEGER_COLUMN.getName()), new ASTScalar(1) });
Expression right = new ASTScalar(1);
Expression equal = new ASTEqual();
equal.setOperand(0, left);
equal.setOperand(1, right);
SelectQuery query = new SelectQuery(ReturnTypesMap1.class);
query.setQualifier(equal);
List<ReturnTypesMap1> objects = context.performQuery(query);
assertEquals(2, objects.size());
}
use of org.apache.cayenne.exp.parser.ASTScalar in project cayenne by apache.
the class FunctionExpressionFactoryTest method substringExp.
@Test
public void substringExp() throws Exception {
Expression exp1 = FunctionExpressionFactory.substringExp(Artist.ARTIST_NAME.path(), 10, 15);
Expression exp2 = FunctionExpressionFactory.substringExp(Artist.ARTIST_NAME.getName(), 10, 15);
Expression exp3 = FunctionExpressionFactory.substringExp(Artist.ARTIST_NAME.path(), new ASTScalar(10), new ASTScalar(15));
assertTrue(exp1 instanceof ASTSubstring);
assertEquals(3, exp1.getOperandCount());
assertEquals(Artist.ARTIST_NAME.path(), exp1.getOperand(0));
assertEquals(10, exp1.getOperand(1));
assertEquals(15, exp1.getOperand(2));
assertEquals(exp1, exp2);
assertEquals(exp2, exp3);
}
use of org.apache.cayenne.exp.parser.ASTScalar in project cayenne by apache.
the class FunctionExpressionFactoryTest method concatExp.
@Test
public void concatExp() throws Exception {
Expression exp1 = FunctionExpressionFactory.concatExp(Artist.ARTIST_NAME.path(), new ASTScalar("abc"), Artist.DATE_OF_BIRTH.path());
assertTrue(exp1 instanceof ASTConcat);
assertEquals(3, exp1.getOperandCount());
assertEquals(Artist.ARTIST_NAME.path(), exp1.getOperand(0));
assertEquals("abc", exp1.getOperand(1));
assertEquals(Artist.DATE_OF_BIRTH.path(), exp1.getOperand(2));
Expression exp2 = FunctionExpressionFactory.concatExp(Artist.ARTIST_NAME.getName(), Artist.DATE_OF_BIRTH.getName(), Artist.PAINTING_ARRAY.getName());
assertTrue(exp2 instanceof ASTConcat);
assertEquals(3, exp2.getOperandCount());
assertEquals(Artist.ARTIST_NAME.path(), exp2.getOperand(0));
assertEquals(Artist.DATE_OF_BIRTH.path(), exp2.getOperand(1));
assertEquals(Artist.PAINTING_ARRAY.path(), exp2.getOperand(2));
}
Aggregations