You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2021/11/26 16:20:58 UTC
[jackrabbit-oak] branch trunk updated: OAK-9625 (remove trailing whitespace)
This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 44b79ab OAK-9625 (remove trailing whitespace)
44b79ab is described below
commit 44b79ab6ed44f5bd3e0bf278198a54291d0823d7
Author: thomasm <th...@apache.org>
AuthorDate: Fri Nov 26 17:20:17 2021 +0100
OAK-9625 (remove trailing whitespace)
---
.../oak/query/xpath/XPathToSQL2Converter.java | 60 ++++----
.../apache/jackrabbit/oak/jcr/query/QueryTest.java | 168 ++++++++++-----------
2 files changed, 114 insertions(+), 114 deletions(-)
diff --git a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
index 711c7fd..2335e64 100644
--- a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
+++ b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
@@ -33,18 +33,18 @@ import java.util.Locale;
* This class can can convert a XPATH query to a SQL2 query.
*/
public class XPathToSQL2Converter {
-
+
/**
- * Optimize queries of the form "from [nt:base] where [jcr:primaryType] = 'x'"
+ * Optimize queries of the form "from [nt:base] where [jcr:primaryType] = 'x'"
* to "from [x] where [jcr:primaryType] = 'x'".
* Enabled by default.
*/
public static final boolean NODETYPE_OPTIMIZATION = Boolean.parseBoolean(
System.getProperty("oak.xpathNodeTypeOptimization", "true"));
-
+
/**
* Convert queries of the form "where [jcr:primaryType] = 'x' or [jcr:primaryType] = 'y'"
- * to "select ... where [jcr:primaryType] = 'x' union select ... where [jcr:primaryType] = 'y'".
+ * to "select ... where [jcr:primaryType] = 'x' union select ... where [jcr:primaryType] = 'y'".
* If disabled, only one query with "where [jcr:primaryType] in ('x', 'y') is used.
* Enabled by default.
*/
@@ -88,11 +88,11 @@ public class XPathToSQL2Converter {
statement = statement.optimize();
return statement.toString();
}
-
+
private Statement convertToStatement(String query) throws ParseException {
-
+
query = query.trim();
-
+
Statement statement = new Statement();
if (query.startsWith("explain ")) {
@@ -103,19 +103,19 @@ public class XPathToSQL2Converter {
query = query.substring("measure".length()).trim();
statement.setMeasure(true);
}
-
+
if (query.isEmpty()) {
// special case, will always result in an empty result
query = "//jcr:root";
}
-
+
statement.setOriginalQuery(query);
-
+
initialize(query);
-
+
expected = new ArrayList<String>();
read();
-
+
if (currentTokenType == END) {
throw getSyntaxError("the query may not be empty");
}
@@ -126,11 +126,11 @@ public class XPathToSQL2Converter {
boolean startOfQuery = true;
while (true) {
-
+
// if true, path or nodeType conditions are not allowed
boolean shortcut = false;
boolean slash = readIf("/");
-
+
if (!slash) {
if (startOfQuery) {
// the query doesn't start with "/"
@@ -209,7 +209,7 @@ public class XPathToSQL2Converter {
currentSelector.nodeName = "jcr:xmltext";
} else {
currentSelector.path = PathUtils.concat(currentSelector.path, "jcr:xmltext");
- }
+ }
} else if ("element".equals(identifier)) {
// "...element(..."
if (readIf(")")) {
@@ -298,7 +298,7 @@ public class XPathToSQL2Converter {
} else if (readIf("rep:spellcheck")) {
// only rep:spellcheck() is currently supported
read("(");
- read(")");
+ read(")");
Expression.Property p = new Expression.Property(currentSelector, "rep:spellcheck()", false);
statement.addSelectColumn(p);
} else if (readIf("rep:suggest")) {
@@ -410,7 +410,7 @@ public class XPathToSQL2Converter {
statement.setColumnSelector(currentSelector);
statement.setSelectors(selectors);
statement.setQueryOptions(options);
-
+
Expression where = null;
for (Selector s : selectors) {
where = Expression.and(where, s.condition);
@@ -418,7 +418,7 @@ public class XPathToSQL2Converter {
statement.setWhere(where);
return statement;
}
-
+
private void appendNodeName(String name) {
if (!currentSelector.isChild) {
currentSelector.nodeName = name;
@@ -435,7 +435,7 @@ public class XPathToSQL2Converter {
}
}
}
-
+
/**
* Switch back to the old selector when reading a property. This occurs
* after reading a "/", but then reading a property or a list of properties.
@@ -464,8 +464,8 @@ public class XPathToSQL2Converter {
String n = currentSelector.nodeName;
// encode again, because it will be decoded again
n = ISO9075.encode(n);
- Expression.Condition c = new Expression.Condition(f, "=",
- Expression.Literal.newString(n),
+ Expression.Condition c = new Expression.Condition(f, "=",
+ Expression.Literal.newString(n),
Expression.PRECEDENCE_CONDITION);
condition = Expression.and(condition, c);
}
@@ -485,7 +485,7 @@ public class XPathToSQL2Converter {
c.params.add(new Expression.SelectorExpr(currentSelector));
c.params.add(new Expression.SelectorExpr(selectors.get(selectors.size() - 1)));
joinCondition = c;
- }
+ }
} else if (currentSelector.isParent) {
if (isFirstSelector) {
throw getSyntaxError();
@@ -602,7 +602,7 @@ public class XPathToSQL2Converter {
c = new Expression.Condition(left, "<=", parseExpression(), Expression.PRECEDENCE_CONDITION);
} else if (readIf(">=")) {
c = new Expression.Condition(left, ">=", parseExpression(), Expression.PRECEDENCE_CONDITION);
- // TODO support "x eq y"? it seems this only matches for single value properties?
+ // TODO support "x eq y"? it seems this only matches for single value properties?
// } else if (readIf("eq")) {
// c = new Condition(left, "==", parseExpression(), Expression.PRECEDENCE_CONDITION);
} else {
@@ -701,7 +701,7 @@ public class XPathToSQL2Converter {
private Expression parseFunction(String functionName) throws ParseException {
if ("jcr:like".equals(functionName)) {
- Expression.Condition c = new Expression.Condition(parseExpression(),
+ Expression.Condition c = new Expression.Condition(parseExpression(),
"like", null, Expression.PRECEDENCE_CONDITION);
read(",");
c.right = parseExpression();
@@ -791,7 +791,7 @@ public class XPathToSQL2Converter {
read(")");
return new Expression.Suggest(term);
} else {
- throw getSyntaxError("jcr:like | jcr:contains | jcr:score | xs:dateTime | " +
+ throw getSyntaxError("jcr:like | jcr:contains | jcr:score | xs:dateTime | " +
"fn:lower-case | fn:upper-case | fn:name | rep:similar | rep:spellcheck | rep:suggest");
}
}
@@ -826,10 +826,10 @@ public class XPathToSQL2Converter {
}
return new Expression.Property(currentSelector, readPathSegment(), false);
}
-
+
/**
* Read open bracket (optional), and optional dot, and close bracket.
- *
+ *
* @param readOpenBracket whether to read the open bracket (false if this
* was already read)
* @throws ParseException if close bracket or the dot were not read
@@ -977,7 +977,7 @@ public class XPathToSQL2Converter {
// for example in "fn:lower-case"
// the '.' can be part of a name,
// for example in "@offloading.status"
- if (type != CHAR_NAME && type != CHAR_VALUE
+ if (type != CHAR_NAME && type != CHAR_VALUE
&& chars[i] != '-'
&& chars[i] != '.') {
break;
@@ -1152,7 +1152,7 @@ public class XPathToSQL2Converter {
}
return new ParseException("Query:\n" + query, index);
}
-
+
private Statement convertToUnion(String query, Statement statement,
int startParseIndex) throws ParseException {
int start = query.indexOf("(", startParseIndex);
@@ -1186,7 +1186,7 @@ public class XPathToSQL2Converter {
}
}
String or = partList.substring(lastOrIndex, parseIndex - 1);
- parts.add(or);
+ parts.add(or);
String end = partList.substring(parseIndex);
Statement result = null;
ArrayList<Order> orderList = null;
diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
index ca4df14..7845650 100644
--- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
+++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryTest.java
@@ -69,12 +69,12 @@ public class QueryTest extends AbstractRepositoryTest {
public QueryTest(NodeStoreFixture fixture) {
super(fixture);
}
-
+
@Test
public void traversalOption() throws Exception {
Session session = getAdminSession();
QueryManager qm = session.getWorkspace().getQueryManager();
-
+
// for union queries:
// both subqueries use an index
assertTrue(isValidQuery(qm, Query.JCR_SQL2,
@@ -88,22 +88,22 @@ public class QueryTest extends AbstractRepositoryTest {
// first one does, second one does not
assertFalse(isValidQuery(qm, Query.JCR_SQL2,
"select * from [nt:base] where [x] = 2 or [jcr:uuid] = 1 option(traversal fail)"));
-
+
// queries that possibly use traversal (depending on the join order)
assertTrue(isValidQuery(qm, "xpath",
"/jcr:root/content//*/jcr:content[@jcr:uuid='1'] option(traversal fail)"));
assertTrue(isValidQuery(qm, "xpath",
"/jcr:root/content/*/jcr:content[@jcr:uuid='1'] option(traversal fail)"));
assertTrue(isValidQuery(qm, Query.JCR_SQL2,
- "select * from [nt:base] as [a] inner join [nt:base] as [b] on ischildnode(b, a) " +
+ "select * from [nt:base] as [a] inner join [nt:base] as [b] on ischildnode(b, a) " +
"where [a].[jcr:uuid] = 1 option(traversal fail)"));
assertTrue(isValidQuery(qm, Query.JCR_SQL2,
- "select * from [nt:base] as [a] inner join [nt:base] as [b] on ischildnode(a, b) " +
+ "select * from [nt:base] as [a] inner join [nt:base] as [b] on ischildnode(a, b) " +
"where [a].[jcr:uuid] = 1 option(traversal fail)"));
// union with joins
assertTrue(isValidQuery(qm, Query.JCR_SQL2,
- "select * from [nt:base] as [a] inner join [nt:base] as [b] on ischildnode(a, b) " +
+ "select * from [nt:base] as [a] inner join [nt:base] as [b] on ischildnode(a, b) " +
"where ischildnode([a], '/') or [a].[jcr:uuid] = 1 option(traversal fail)"));
assertFalse(isValidQuery(qm, "xpath",
@@ -118,7 +118,7 @@ public class QueryTest extends AbstractRepositoryTest {
"select * from [nt:base] option(traversal ok)"));
assertTrue(isValidQuery(qm, Query.JCR_SQL2,
"select * from [nt:base] option(traversal warn)"));
-
+
// the following is not really traversal, it is just listing child nodes:
assertTrue(isValidQuery(qm, "xpath",
"/jcr:root/*[@test] option(traversal fail)"));
@@ -127,7 +127,7 @@ public class QueryTest extends AbstractRepositoryTest {
"/jcr:root/oak:index[@test] option(traversal fail)"));
}
-
+
private static boolean isValidQuery(QueryManager qm, String language, String query) throws RepositoryException {
try {
qm.createQuery(query, language).execute();
@@ -137,7 +137,7 @@ public class QueryTest extends AbstractRepositoryTest {
return false;
}
}
-
+
@Test
public void firstSelector() throws Exception {
Session session = getAdminSession();
@@ -167,80 +167,80 @@ public class QueryTest extends AbstractRepositoryTest {
// b.setProperty("join", a.getProperty("jcr:uuid").getString(), PropertyType.STRING);
session.save();
assertEquals("/a",
- getNodeList(session,
- "select [a].* from [nt:unstructured] as [a] "+
- "inner join [nt:unstructured] as [b] " +
+ getNodeList(session,
+ "select [a].* from [nt:unstructured] as [a] "+
+ "inner join [nt:unstructured] as [b] " +
"on [a].[jcr:uuid] = [b].[join] where issamenode([a], '/a')",
Query.JCR_SQL2));
assertEquals("/a",
- getNodeList(session,
- "select [a].* from [nt:unstructured] as [a] "+
- "inner join [nt:unstructured] as [b] " +
+ getNodeList(session,
+ "select [a].* from [nt:unstructured] as [a] "+
+ "inner join [nt:unstructured] as [b] " +
"on [b].[join] = [a].[jcr:uuid] where issamenode([a], '/a')",
Query.JCR_SQL2));
}
-
+
@Test
public void typeConversion() throws Exception {
Session session = getAdminSession();
Node root = session.getRootNode();
-
+
Node test = root.addNode("test");
test.addNode("a", "oak:Unstructured").setProperty("time", "2001-01-01T00:00:00.000Z", PropertyType.DATE);
test.addNode("b", "oak:Unstructured").setProperty("time", "2010-01-01T00:00:00.000Z", PropertyType.DATE);
test.addNode("c", "oak:Unstructured").setProperty("time", "2020-01-01T00:00:00.000Z", PropertyType.DATE);
session.save();
-
+
assertEquals("/test/c",
- getNodeList(session,
+ getNodeList(session,
"select [jcr:path] " +
- "from [nt:base] " +
+ "from [nt:base] " +
"where [time] > '2011-01-01T00:00:00.000z'", Query.JCR_SQL2));
}
-
+
@Test
public void twoSelectors() throws Exception {
Session session = getAdminSession();
Node root = session.getRootNode();
-
+
Node test = root.addNode("test");
test.addNode("testNode", "oak:Unstructured");
session.save();
-
+
assertEquals("/test/testNode",
- getNodeList(session,
+ getNodeList(session,
"select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* " +
"from [nt:base] as a " +
- "inner join [nt:base] as b " +
+ "inner join [nt:base] as b " +
"on ischildnode(b, a) " +
"where issamenode(a, '/test')", Query.JCR_SQL2));
assertEquals("/test/testNode",
- getNodeList(session,
+ getNodeList(session,
"select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* " +
"from [nt:base] as b " +
- "inner join [nt:base] as a " +
+ "inner join [nt:base] as a " +
"on ischildnode(b, a) " +
"where issamenode(b, '/test/testNode')", Query.JCR_SQL2));
assertEquals("/test",
- getNodeList(session,
+ getNodeList(session,
"select a.[jcr:path] as [jcr:path], a.[jcr:score] as [jcr:score], a.* " +
"from [nt:base] as a " +
- "inner join [nt:base] as b " +
+ "inner join [nt:base] as b " +
"on ischildnode(b, a) " +
"where issamenode(a, '/test')", Query.JCR_SQL2));
-
+
assertEquals("/test",
- getNodeList(session,
+ getNodeList(session,
"select a.[jcr:path] as [jcr:path], a.[jcr:score] as [jcr:score], a.* " +
"from [nt:base] as b " +
- "inner join [nt:base] as a " +
+ "inner join [nt:base] as a " +
"on ischildnode(b, a) " +
"where issamenode(b, '/test/testNode')", Query.JCR_SQL2));
}
-
+
private static String getNodeList(Session session, String query, String language) throws RepositoryException {
QueryResult r = session.getWorkspace().getQueryManager()
.createQuery(query, language).execute();
@@ -250,16 +250,16 @@ public class QueryTest extends AbstractRepositoryTest {
if (buff.length() > 0) {
buff.append(", ");
}
- buff.append(it.nextNode().getPath());
+ buff.append(it.nextNode().getPath());
}
return buff.toString();
}
-
+
@Test
public void noDeclaringNodeTypesIndex() throws Exception {
Session session = getAdminSession();
Node root = session.getRootNode();
-
+
// set declaringNodeTypes to an empty array
Node nodeTypeIndex = root.getNode("oak:index").getNode("nodetype");
nodeTypeIndex.setProperty("declaringNodeTypes", new String[] {
@@ -279,7 +279,7 @@ public class QueryTest extends AbstractRepositoryTest {
assertTrue(it.hasNext());
assertEquals("/test/testNode", it.nextNode().getPath());
}
-
+
@Test
public void propertyIndexWithDeclaringNodeTypeAndRelativQuery() throws RepositoryException {
Session session = getAdminSession();
@@ -290,26 +290,26 @@ public class QueryTest extends AbstractRepositoryTest {
r = session.getWorkspace().getQueryManager()
.createQuery("explain " + query, "xpath").execute();
rit = r.getRows();
- assertEquals("[rep:Authorizable] as [a] /* property principalName = admin " +
- "where [a].[rep:principalName] = 'admin' */",
+ assertEquals("[rep:Authorizable] as [a] /* property principalName = admin " +
+ "where [a].[rep:principalName] = 'admin' */",
rit.nextRow().getValue("plan").getString());
-
+
query = "//element(*, rep:Authorizable)[admin/@rep:principalName = 'admin']";
r = session.getWorkspace().getQueryManager()
.createQuery("explain " + query, "xpath").execute();
rit = r.getRows();
- assertEquals("[rep:Authorizable] as [a] /* nodeType " +
- "Filter(query=explain select [jcr:path], [jcr:score], * " +
- "from [rep:Authorizable] as a " +
- "where [admin/rep:principalName] = 'admin' " +
- "/* xpath: //element(*, rep:Authorizable)[" +
- "admin/@rep:principalName = 'admin'] */, path=*, " +
- "property=[admin/rep:principalName=[admin]]) " +
- "where [a].[admin/rep:principalName] = 'admin' */",
+ assertEquals("[rep:Authorizable] as [a] /* nodeType " +
+ "Filter(query=explain select [jcr:path], [jcr:score], * " +
+ "from [rep:Authorizable] as a " +
+ "where [admin/rep:principalName] = 'admin' " +
+ "/* xpath: //element(*, rep:Authorizable)[" +
+ "admin/@rep:principalName = 'admin'] */, path=*, " +
+ "property=[admin/rep:principalName=[admin]]) " +
+ "where [a].[admin/rep:principalName] = 'admin' */",
rit.nextRow().getValue("plan").getString());
-
+
}
-
+
@Test
public void date() throws Exception {
Session session = getAdminSession();
@@ -318,7 +318,7 @@ public class QueryTest extends AbstractRepositoryTest {
Node t2 = session.getRootNode().addNode("t2");
t2.setProperty("x", "2007-06-22T01:02:03.000Z", PropertyType.DATE);
session.save();
-
+
String query = "//*[x='a' or x='b']";
QueryResult r = session.getWorkspace().
getQueryManager().createQuery(
@@ -326,18 +326,18 @@ public class QueryTest extends AbstractRepositoryTest {
NodeIterator it = r.getNodes();
assertFalse(it.hasNext());
}
-
+
@Test
public void unicode() throws Exception {
Session session = getAdminSession();
Node content = session.getRootNode().addNode("test");
String[][] list = {
- {"three", "\u00e4\u00f6\u00fc"},
- {"two", "123456789"},
- {"one", "\u3360\u3361\u3362\u3363\u3364\u3365\u3366\u3367\u3368\u3369"},
+ {"three", "\u00e4\u00f6\u00fc"},
+ {"two", "123456789"},
+ {"one", "\u3360\u3361\u3362\u3363\u3364\u3365\u3366\u3367\u3368\u3369"},
};
for (String[] pair : list) {
- content.addNode(pair[0]).setProperty("prop",
+ content.addNode(pair[0]).setProperty("prop",
"propValue testSearch " + pair[1] + " data");
}
session.save();
@@ -351,9 +351,9 @@ public class QueryTest extends AbstractRepositoryTest {
String path = it.nextNode().getPath();
assertEquals("/test/" + pair[0], path);
assertFalse(it.hasNext());
- }
+ }
}
-
+
@Test
@Ignore("OAK-1215")
public void anyChildNodeProperty() throws Exception {
@@ -370,7 +370,7 @@ public class QueryTest extends AbstractRepositoryTest {
String path = it.nextNode().getPath();
assertEquals("/test/one", path);
assertFalse(it.hasNext());
-
+
query = "//*[*/*/@prop = 'hello']";
r = session.getWorkspace().getQueryManager().createQuery(
query, "xpath").execute();
@@ -443,16 +443,16 @@ public class QueryTest extends AbstractRepositoryTest {
QueryManager qm = session.getWorkspace().getQueryManager();
Query q;
q = qm.createQuery(
- "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE(s,[/hello])",
+ "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE(s,[/hello])",
Query.JCR_SQL2);
assertEquals("/hello/world", getPaths(q));
q = qm.createQuery(
- "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE(s,\"/hello\")",
+ "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE(s,\"/hello\")",
Query.JCR_SQL2);
assertEquals("/hello/world", getPaths(q));
try {
q = qm.createQuery(
- "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE(s,[\"/hello\"])",
+ "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE(s,[\"/hello\"])",
Query.JCR_SQL2);
getPaths(q);
fail();
@@ -472,10 +472,10 @@ public class QueryTest extends AbstractRepositoryTest {
session.save();
QueryManager qm = session.getWorkspace().getQueryManager();
Query q;
-
- q = qm.createQuery("select a.[jcr:path] from [nt:base] as a " +
+
+ q = qm.createQuery("select a.[jcr:path] from [nt:base] as a " +
"inner join [nt:base] as b " +
- "on ischildnode(a, b) " +
+ "on ischildnode(a, b) " +
"where a.x = 1 or a.x = 2 or b.x = 3 or b.x = 4", Query.JCR_SQL2);
assertEquals("/hello", getPaths(q));
@@ -492,18 +492,18 @@ public class QueryTest extends AbstractRepositoryTest {
session.save();
QueryManager qm = session.getWorkspace().getQueryManager();
Query q;
-
+
q = qm.createQuery("/jcr:root/hel_x006c_o/*", Query.XPATH);
assertEquals("/hello/world", getPaths(q));
-
+
q = qm.createQuery("//hel_x006c_o", Query.XPATH);
assertEquals("/hello", getPaths(q));
-
+
q = qm.createQuery("//element(hel_x006c_o, nt:base)", Query.XPATH);
assertEquals("/hello", getPaths(q));
}
-
+
private static String getPaths(Query q) throws RepositoryException {
QueryResult r = q.execute();
RowIterator it = r.getRows();
@@ -631,7 +631,7 @@ public class QueryTest extends AbstractRepositoryTest {
assertFalse(it.hasNext());
}
}
-
+
@Test
public void limit() throws RepositoryException {
Session session = getAdminSession();
@@ -661,7 +661,7 @@ public class QueryTest extends AbstractRepositoryTest {
assertEquals(l, r.getRows().getSize());
assertEquals(l, r.getNodes().getSize());
Row row;
-
+
for (int x = offset + 1, i = 0; i < limit && x < 4; i++, x++) {
assertTrue(it.hasNext());
row = it.nextRow();
@@ -693,17 +693,17 @@ public class QueryTest extends AbstractRepositoryTest {
assertEquals(new HashSet<String>(Arrays.asList("/folder1", "/folder2", "/folder2/folder3")),
paths);
}
-
+
@Test
public void noLiterals() throws RepositoryException {
Session session = getAdminSession();
ValueFactory vf = session.getValueFactory();
QueryManager qm = session.getWorkspace().getQueryManager();
-
+
// insecure
try {
Query q = qm.createQuery(
- "select text from [nt:base] where password = 'x'",
+ "select text from [nt:base] where password = 'x'",
Query.JCR_SQL2 + "-noLiterals");
q.execute();
fail();
@@ -714,7 +714,7 @@ public class QueryTest extends AbstractRepositoryTest {
// secure
Query q = qm.createQuery(
- "select text from [nt:base] where password = $p",
+ "select text from [nt:base] where password = $p",
Query.JCR_SQL2 + "-noLiterals");
q.bindValue("p", vf.createValue("x"));
q.execute();
@@ -814,7 +814,7 @@ public class QueryTest extends AbstractRepositoryTest {
}
}
}
-
+
@Test
public void testOak1128() throws RepositoryException {
Session session = createAdminSession();
@@ -881,7 +881,7 @@ public class QueryTest extends AbstractRepositoryTest {
assertFalse(ni.hasNext());
session.logout();
}
-
+
@Test
public void approxCount() throws Exception {
Session session = createAdminSession();
@@ -906,7 +906,7 @@ public class QueryTest extends AbstractRepositoryTest {
}
double c = getCost(session, "//*[@x=1]");
assertTrue("cost: " + c, c > 0 && c < 100000);
-
+
// *without* the counter index, the estimated cost to traverse is high
session.getNode("/oak:index/counter").remove();
session.save();
@@ -921,8 +921,8 @@ public class QueryTest extends AbstractRepositoryTest {
Session session = createAdminSession();
String xpath = "/jcr:root//element(*,rep:User)[xyz/@jcr:primaryType]";
assertPlan(getPlan(session, xpath), "[rep:User] as [a] /* nodeType");
-
- session.getNode("/oak:index/nodetype").setProperty("declaringNodeTypes",
+
+ session.getNode("/oak:index/nodetype").setProperty("declaringNodeTypes",
new String[]{"oak:Unstructured"}, PropertyType.NAME);
session.save();
@@ -945,7 +945,7 @@ public class QueryTest extends AbstractRepositoryTest {
} catch (InvalidQueryException e) {
// expected
}
-
+
session.logout();
}
@@ -976,7 +976,7 @@ public class QueryTest extends AbstractRepositoryTest {
private static void assertPlan(String plan, String planPrefix) {
assertTrue("Unexpected plan: " + plan, plan.startsWith(planPrefix));
}
-
+
private static String getPlan(Session session, String xpath) throws RepositoryException {
QueryManager qm = session.getWorkspace().getQueryManager();
QueryResult qr = qm.createQuery("explain " + xpath, "xpath").execute();
@@ -984,7 +984,7 @@ public class QueryTest extends AbstractRepositoryTest {
String plan = r.getValue("plan").getString();
return plan;
}
-
+
private static double getCost(Session session, String xpath) throws RepositoryException {
QueryManager qm = session.getWorkspace().getQueryManager();
QueryResult qr = qm.createQuery("explain measure " + xpath, "xpath").execute();
@@ -995,7 +995,7 @@ public class QueryTest extends AbstractRepositoryTest {
double c = Double.parseDouble(json.getProperties().get("a"));
return c;
}
-
+
private static JsonObject parseJson(String json) {
JsopTokenizer t = new JsopTokenizer(json);
t.read('{');