use of org.intermine.objectstore.query.SimpleConstraint in project intermine by intermine.
the class SetupDataTestCase method queryClassBagNotViaNand.
/*
* SELECT a1_.id, a2_ FROM ?::Department AS a1_, Employee AS a2_ WHERE NOT (a1_.employees CONTAINS a2_ AND 1 = 1)
*/
public static Query queryClassBagNotViaNand() throws Exception {
Query q = new Query();
QueryClassBag qcb = new QueryClassBag(Department.class, Arrays.asList(new Object[] { data.get("DepartmentA1"), data.get("DepartmentB1") }));
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qcb);
q.addFrom(qc);
q.addToSelect(new QueryField(qcb));
q.addToSelect(qc);
ConstraintSet cs = new ConstraintSet(ConstraintOp.NAND);
cs.addConstraint(new ContainsConstraint(new QueryCollectionReference(qcb, "employees"), ConstraintOp.CONTAINS, qc));
cs.addConstraint(new SimpleConstraint(new QueryValue(new Integer(1)), ConstraintOp.EQUALS, new QueryValue(new Integer(1))));
q.setConstraint(cs);
q.setDistinct(false);
return q;
}
use of org.intermine.objectstore.query.SimpleConstraint in project intermine by intermine.
the class SetupDataTestCase method queryClassBagNotViaNor.
/*
* SELECT a1_.id, a2_ FROM ?::Department AS a1_, Employee AS a2_ WHERE NOT (a1_.employees CONTAINS a2_ OR 1 = 1)
*/
public static Query queryClassBagNotViaNor() throws Exception {
Query q = new Query();
QueryClassBag qcb = new QueryClassBag(Department.class, Arrays.asList(new Object[] { data.get("DepartmentA1"), data.get("DepartmentB1") }));
QueryClass qc = new QueryClass(Employee.class);
q.addFrom(qcb);
q.addFrom(qc);
q.addToSelect(new QueryField(qcb));
q.addToSelect(qc);
ConstraintSet cs = new ConstraintSet(ConstraintOp.NOR);
cs.addConstraint(new ContainsConstraint(new QueryCollectionReference(qcb, "employees"), ConstraintOp.CONTAINS, qc));
cs.addConstraint(new SimpleConstraint(new QueryValue(new Integer(1)), ConstraintOp.EQUALS, new QueryValue(new Integer(1))));
q.setConstraint(cs);
q.setDistinct(false);
return q;
}
use of org.intermine.objectstore.query.SimpleConstraint in project intermine by intermine.
the class SqlGeneratorTest method testQueryValueUnderscoreInEquals.
/**
* Expect underscores to be unescaped in other queries *
*/
public void testQueryValueUnderscoreInEquals() throws Exception {
QueryValue right = new QueryValue("Hello_World");
QueryValue left = new QueryValue("HelloXWorld");
SimpleConstraint con = new SimpleConstraint(left, ConstraintOp.EQUALS, right);
SqlGenerator.State state = new SqlGenerator.State();
StringBuffer buffer = state.getWhereBuffer();
SqlGenerator.simpleConstraintToString(state, buffer, con, null);
assertEquals("'HelloXWorld' = 'Hello_World'", buffer.toString());
}
use of org.intermine.objectstore.query.SimpleConstraint in project intermine by intermine.
the class SqlGeneratorTest method testQueryValueUnderscoreInMatch.
/**
* Expect Underscores to not be escaped in LIKE queries *
*/
public void testQueryValueUnderscoreInMatch() throws Exception {
QueryValue right = new QueryValue("%Hello_World");
QueryValue left = new QueryValue("Hello-World");
SimpleConstraint con = new SimpleConstraint(left, ConstraintOp.MATCHES, right);
SqlGenerator.State state = new SqlGenerator.State();
StringBuffer buffer = state.getWhereBuffer();
SqlGenerator.simpleConstraintToString(state, buffer, con, null);
assertEquals("'Hello-World' LIKE '%Hello_World'", buffer.toString());
}
use of org.intermine.objectstore.query.SimpleConstraint in project intermine by intermine.
the class SqlGeneratorTest method testQueryValueEscapedOpsInMatch.
/**
* Expect Underscores to not be escaped in LIKE queries *
*/
public void testQueryValueEscapedOpsInMatch() throws Exception {
QueryValue right = new QueryValue("\\%Hello_Under\\_Score%");
QueryValue left = new QueryValue("%Hello-Under_Score!");
SimpleConstraint con = new SimpleConstraint(left, ConstraintOp.MATCHES, right);
SqlGenerator.State state = new SqlGenerator.State();
StringBuffer buffer = state.getWhereBuffer();
SqlGenerator.simpleConstraintToString(state, buffer, con, null);
String expected = "'%Hello-Under_Score!' LIKE E'\\\\%Hello_Under\\\\_Score%'";
assertEquals(expected, buffer.toString());
}
Aggregations