Hi folks,

please create and save a property "dateProp" with a date value (and date type)
in the repository root. Then query it with sql (SELECT dateProp FROM rep:root)
or xpath (/element(*, rep:root)/@dateProp)

For example with curl (and xmllint to format the xml output) ...

curl \
  --request SEARCH --data @- --user admin:admin --silent \
  http://localhost:8080/jackrabbit/server/default <<END |
<D:searchrequest xmlns:D="DAV:">
  <sql><![CDATA[SELECT dateProp FROM rep:root]]></sql>
</D:searchrequest>
END
xmllint --format -

... you should get a response like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<D:multistatus xmlns:D="DAV:">
  <D:response>
    <D:href>http://localhost:8080/jackrabbit/server/default/jcr%3aroot/</D:href>
    <D:propstat>
      <D:prop>
        <dcr:search-result-property 
xmlns:dcr="http://www.day.com/jcr/webdav/1.0";>
          <dcr:column>
            <dcr:name>dateProp</dcr:name>
            <dcr:value 
dcr:type="String">2017-02-08T09:00:16.000+01:00</dcr:value>
          </dcr:column>
          <dcr:column>
            <dcr:name>jcr:path</dcr:name>
            <dcr:value dcr:type="Path">/</dcr:value>
            <dcr:selectorName>s</dcr:selectorName>
          </dcr:column>
          <dcr:column>
            <dcr:name>jcr:score</dcr:name>
            <dcr:value dcr:type="Double">0.0</dcr:value>
            <dcr:selectorName>s</dcr:selectorName>
          </dcr:column>
        </dcr:search-result-property>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
  <D:responsedescription>dateProp jcr:path jcr:score</D:responsedescription>
</D:multistatus>

The property "dateProp" is returned as

  <dcr:value dcr:type="String">...</dcr:value>

which is wrong IMHO.

If you submit the aquivalent JCR-SQL2-Query ...

curl --request SEARCH --data @- --user admin:admin --silent \
http://localhost:8080/jackrabbit/server/default <<END |
<D:searchrequest xmlns:D="DAV:">
  <JCR-SQL2><![CDATA[SELECT [dateProp] FROM [rep:root]]]></JCR-SQL2>
</D:searchrequest>
END
xmllint --format -

... you get something like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<D:multistatus xmlns:D="DAV:">
  <D:response>
    <D:href>http://localhost:8080/jackrabbit/server/default/jcr%3aroot/</D:href>
    <D:propstat>
      <D:prop>
        <dcr:search-result-property 
xmlns:dcr="http://www.day.com/jcr/webdav/1.0";>
          <dcr:column>
            <dcr:name>dateProp</dcr:name>
            <dcr:value dcr:type="Date">2017-02-08T09:00:16.000+01:00</dcr:value>
          </dcr:column>
          <dcr:column>
            <dcr:name>jcr:path</dcr:name>
            <dcr:value dcr:type="Path">/</dcr:value>
            <dcr:selectorName>rep:root</dcr:selectorName>
          </dcr:column>
          <dcr:column>
            <dcr:name>jcr:score</dcr:name>
            <dcr:value dcr:type="Double">9.901910781860352</dcr:value>
            <dcr:selectorName>rep:root</dcr:selectorName>
          </dcr:column>
        </dcr:search-result-property>
      </D:prop>
      <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
  </D:response>
  <D:responsedescription>dateProp</D:responsedescription>
</D:multistatus>

In this case you get the property "dateProp" correctly as

  <dcr:value dcr:type="Date">...</dcr:value>

There are other differences too: The JCR-SQL2 returns an other jcr:score and
an other responsedescription.

If I submit the sql or xpath query with PHP, PHPCR/jackalope throws an
exception because of the wrong returned property type.

Tested with jackrabbit 2.10.1 and 2.14.0

Reply via email to