use of org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter in project jackrabbit-oak by apache.
the class LargeQueryTest method testCombinedOr.
@Test
public void testCombinedOr() throws ParseException {
StringBuilder buff = new StringBuilder("//*[");
StringBuilder buff2 = new StringBuilder("select [jcr:path], [jcr:score], * from [nt:base] as a where [x] in(");
int step = 111;
for (int i = 0; i < 5000; i++) {
if (i % step == 2) {
if (i > 0) {
buff.append(" or ");
}
buff.append("@x>").append(i);
buff2.append(") union select [jcr:path], [jcr:score], * from [nt:base] as a " + "where [x] > ").append(i);
buff2.append(" union select [jcr:path], [jcr:score], * from [nt:base] as a " + "where [x] in(");
} else {
if (i > 0) {
buff.append(" or ");
}
buff.append("@x=").append(i);
if (i > 0 && i % step != 3) {
buff2.append(", ");
}
buff2.append(i);
}
}
buff.append("]");
buff2.append(")");
String xpath = buff.toString();
XPathToSQL2Converter conv = new XPathToSQL2Converter();
String sql2 = conv.convert(xpath);
buff2.append(" /* xpath: ").append(xpath).append(" */");
assertEquals(buff2.toString(), sql2);
}
use of org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter in project jackrabbit-oak by apache.
the class LargeQueryTest method testSimpleOr.
@Test
public void testSimpleOr() throws ParseException {
StringBuilder buff = new StringBuilder("//*[");
StringBuilder buff2 = new StringBuilder("select [jcr:path], [jcr:score], * from [nt:base] as a where [x] in(");
for (int i = 0; i < 100000; i++) {
if (i > 0) {
buff.append(" or ");
buff2.append(", ");
}
buff.append("@x=").append(i);
buff2.append(i);
}
buff.append("]");
buff2.append(")");
String xpath = buff.toString();
XPathToSQL2Converter conv = new XPathToSQL2Converter();
String sql2 = conv.convert(xpath);
buff2.append(" /* xpath: ").append(xpath).append(" */");
assertEquals(buff2.toString(), sql2);
}
use of org.apache.jackrabbit.oak.query.xpath.XPathToSQL2Converter in project jackrabbit-oak by apache.
the class SQL2ParserTest method testUnwrappedOr.
// see OAK-OAK-830: XPathToSQL2Converter fails to wrap or clauses
@Test
public void testUnwrappedOr() throws ParseException {
String q = new XPathToSQL2Converter().convert("/jcr:root/home//test/* [@type='t1' or @type='t2' or @type='t3']");
String token = "and b.[type] in('t1', 't2', 't3')";
assertTrue(q.contains(token));
}
Aggregations