Details
Description
On a XWiki 5.2.2 installation with an oracle backend the Rest call to
/rest/wikis/xwiki/spaces/Sandbox/pages/HistTest/history
produces the following output, despite the site has revisions (minor and major):
<history/>
I studied the Java file PageHistoryResourceImpl.java and tried to nail down the problem with the following groovy macro (it executes the same XWQL query as PageHistoryResourceImpl):
{{groovy}}
import org.xwiki.query.Query;
def order = "desc";
def spaceName = "Sandbox";
def pageName = "HistTest";
def number = 100;
def start = 0;
def query = String.format("select doc.space, doc.name, doc.language, rcs.id, rcs.date, rcs.author, rcs.comment"
+ " from XWikiRCSNodeInfo as rcs, XWikiDocument as doc where rcs.id.docId = doc.id and"
+ " doc.space = :space and doc.name = :name and doc.language = :language"
+ " order by rcs.date %s, rcs.id.version1 %s, rcs.id.version2 %s", order, order, order);
def res = xwiki.queryManager.createQuery(query, Query.XWQL)
.bindValue("space", spaceName)
.bindValue("name", pageName)
.bindValue("language", "")
.setLimit(number)
.setOffset(start)
.execute();
println "Found $res.size entries"
res.each() { row -> println row }
{{/groovy}}
The query in the groovy macro does not produce a result on oracle , on mysql it does.
It seems that the language column of all Xwiki documents on oracle have the value null, but the query expects an empty string.
I changed the query to
def query = String.format("select doc.space, doc.name, doc.language, rcs.id, rcs.date, rcs.author, rcs.comment" + " from XWikiRCSNodeInfo as rcs, XWikiDocument as doc where rcs.id.docId = doc.id and" + " doc.space = :space and doc.name = :name and (doc.language = :language or doc.language is null)" + " order by rcs.date %s, rcs.id.version1 %s, rcs.id.version2 %s", order, order, order);
and got the correct result.
What is the default value of the XWikiDocument.language column? xwiki.oracle.hbm.xml allows null values for this column.