use of org.apache.cayenne.exp.parser.ASTEqual in project cayenne by apache.
the class CAY2541IT method testCay2541.
@Test
public void testCay2541() {
ObjectId id = ObjectId.of("ARTIST", "ARTIST_ID", 1);
ASTDbPath astDbPath = new ASTDbPath("ARTIST_ID");
ASTScalar astScalar = new ASTScalar(id);
ASTEqual astEqual = new ASTEqual();
astEqual.setOperand(0, astDbPath);
astEqual.setOperand(1, astScalar);
List<Artist> artistList = ObjectSelect.query(Artist.class).where(astEqual).select(context);
assertEquals(1, artistList.size());
assertEquals("artist1", artistList.get(0).getArtistName());
}
use of org.apache.cayenne.exp.parser.ASTEqual in project cayenne by apache.
the class Cay2666IT method testExpObjPathWithDollarSign.
@Test
public void testExpObjPathWithDollarSign() throws IOException {
Expression exp = ExpressionFactory.exp("obj:x$ = 'A'");
Expression expression = new ASTEqual(new ASTObjPath("x$"), "A");
assertEquals(exp, expression);
exp = ExpressionFactory.exp("x$ = 'A'");
expression = new ASTEqual(new ASTObjPath("x$"), "A");
assertEquals(exp, expression);
exp = ExpressionFactory.exp("obj:x$ = $name", "A");
expression = new ASTEqual(new ASTObjPath("x$"), "A");
assertEquals(exp, expression);
}
use of org.apache.cayenne.exp.parser.ASTEqual in project cayenne by apache.
the class PathAliasesIT method testAliasForPathExp.
@Test
public void testAliasForPathExp() {
ASTPath astPath = new ASTObjPath("paintingArray.p1.galleryName");
astPath.setPathAliases(Collections.singletonMap("a", "toGallery"));
ASTEqual astEqual = new ASTEqual(astPath, "test gallery");
Expression e1 = ExpressionFactory.exp("paintingArray.toGallery#p1.galleryName");
List<Object[]> artists = ObjectSelect.columnQuery(Artist.class, Artist.ARTIST_NAME, PropertyFactory.createBase(e1, String.class)).where(astEqual).select(context);
assertEquals(1, artists.size());
assertEquals("artist4", artists.get(0)[0]);
assertEquals("test gallery", artists.get(0)[1]);
}
use of org.apache.cayenne.exp.parser.ASTEqual in project cayenne by apache.
the class SelectQueryReturnTypesIT method testSelectBitwiseXor.
@Test
public void testSelectBitwiseXor() throws Exception {
if (!accessStackAdapter.supportsBitwiseOps()) {
return;
}
createNumericsDataSet();
// to simplify result checking, do double NOT
Expression left = new ASTBitwiseXor(new Object[] { new ASTObjPath(ReturnTypesMap1.INTEGER_COLUMN.getName()), new ASTScalar(1) });
Expression right = new ASTScalar(5);
Expression equal = new ASTEqual();
equal.setOperand(0, left);
equal.setOperand(1, right);
List<ReturnTypesMap1> objects = ObjectSelect.query(ReturnTypesMap1.class, equal).select(context);
assertEquals(1, objects.size());
assertEquals(4, objects.get(0).getIntegerColumn().intValue());
}
use of org.apache.cayenne.exp.parser.ASTEqual in project cayenne by apache.
the class DB2QualifierTranslator method processColumnWithQuoteSqlIdentifiers.
@Override
protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp) {
SimpleNode parent = null;
if (pathExp instanceof SimpleNode) {
parent = (SimpleNode) ((SimpleNode) pathExp).jjtGetParent();
}
// we need do it by casting the Clob to VARCHAR.
if (parent != null && (parent instanceof ASTEqual || parent instanceof ASTNotEqual) && dbAttr.getType() == Types.CLOB && parent.getOperandCount() == 2 && parent.getOperand(1) instanceof String) {
Integer size = parent.getOperand(1).toString().length() + 1;
out.append("CAST(");
super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp);
out.append(" AS VARCHAR(" + size + "))");
} else {
super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp);
}
}
Aggregations