Felix Oghină (JIRA | 18 Jun 2012 17:20
Picon
Favicon

[Created] (JCR-3347) Searches on properties of type Double give unexpected results

Felix Oghină created JCR-3347:
---------------------------------

             Summary: Searches on properties of type Double give unexpected results
                 Key: JCR-3347
                 URL: https://issues.apache.org/jira/browse/JCR-3347
             Project: Jackrabbit Content Repository
          Issue Type: Bug
         Environment: Linux (Ubuntu 12.04), Oracle Java 1.6.0_31
            Reporter: Felix Oghină

Example:

* have a node with a Double property, e.g. price=25
* The following query returns the node, although it shouldn't:

SELECT * FROM [nt:unstructured] WHERE price > 50

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

Alexander Klimetschek (JIRA | 19 Jun 2012 19:03
Picon
Favicon

[Commented] (JCR-3347) Searches on properties of type Double give unexpected results


    [
https://issues.apache.org/jira/browse/JCR-3347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13396926#comment-13396926
] 

Alexander Klimetschek commented on JCR-3347:
--------------------------------------------

I think you mean the DECIMAL type. The above query should work using a double value for the comparison:

SELECT * FROM [nt:unstructured] WHERE price > 50.0

                
> Searches on properties of type Double give unexpected results
> -------------------------------------------------------------
>
>                 Key: JCR-3347
>                 URL: https://issues.apache.org/jira/browse/JCR-3347
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>         Environment: Linux (Ubuntu 12.04), Oracle Java 1.6.0_31
>            Reporter: Felix Oghină
>
> Example:
> * have a node with a Double property, e.g. price=25
> * The following query returns the node, although it shouldn't:
> SELECT * FROM [nt:unstructured] WHERE price > 50

--
This message is automatically generated by JIRA.
(Continue reading)

Jukka Zitting (JIRA | 20 Jun 2012 01:23
Picon
Favicon

[Resolved] (JCR-3347) Searches on properties of type Double give unexpected results


     [
https://issues.apache.org/jira/browse/JCR-3347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jukka Zitting resolved JCR-3347.
--------------------------------

    Resolution: Not A Problem
      Assignee: Jukka Zitting

You need to be careful with data typing in queries because of the way the underlying index works and because
the query as specified has no way of guessing the actual data type of the referenced "price" property.
Using "price > 50.0" is better than "price > 50" as it uses double comparison instead of integer
comparison. Alternatively you can use explicit type casting for the constant value.

> Searches on properties of type Double give unexpected results
> -------------------------------------------------------------
>
>                 Key: JCR-3347
>                 URL: https://issues.apache.org/jira/browse/JCR-3347
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>         Environment: Linux (Ubuntu 12.04), Oracle Java 1.6.0_31
>            Reporter: Felix Oghină
>            Assignee: Jukka Zitting
>
> Example:
> * have a node with a Double property, e.g. price=25
> * The following query returns the node, although it shouldn't:
> SELECT * FROM [nt:unstructured] WHERE price > 50
(Continue reading)

Felix Oghină (JIRA | 20 Jun 2012 09:37
Picon
Favicon

[Updated] (JCR-3347) Searches on properties of type Decimal give unexpected results


     [
https://issues.apache.org/jira/browse/JCR-3347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Oghină updated JCR-3347:
------------------------------

    Description: 
Example:

* have a node with a Decimal property, e.g. price=25
* The following XPath query returns the node, although it shouldn't:

/jcr:root/content//*[ <at> d_price > 50.0]

  was:
Example:

* have a node with a Double property, e.g. price=25
* The following query returns the node, although it shouldn't:

SELECT * FROM [nt:unstructured] WHERE price > 50

    Environment:     (was: Linux (Ubuntu 12.04), Oracle Java 1.6.0_31)
        Summary: Searches on properties of type Decimal give unexpected results  (was: Searches on properties of
type Double give unexpected results)

> Searches on properties of type Decimal give unexpected results
> --------------------------------------------------------------
>
(Continue reading)

Felix Oghină (JIRA | 20 Jun 2012 09:39
Picon
Favicon

[Commented] (JCR-3347) Searches on properties of type Decimal give unexpected results


    [
https://issues.apache.org/jira/browse/JCR-3347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397331#comment-13397331
] 

Felix Oghină commented on JCR-3347:
-----------------------------------

[~alexander.klimetschek] you are correct, I did mean Decimal.

I also noticed today that I can't duplicate the error with JCR-SQL2 anymore, only with XPath (not sure what
was going on yesterday -- I'm sure I tested the query before posting the issue).

I updated the issue to reflect these findings.

> Searches on properties of type Decimal give unexpected results
> --------------------------------------------------------------
>
>                 Key: JCR-3347
>                 URL: https://issues.apache.org/jira/browse/JCR-3347
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>            Reporter: Felix Oghină
>            Assignee: Jukka Zitting
>
> Example:
> * have a node with a Decimal property, e.g. price=25
> * The following XPath query returns the node, although it shouldn't:
> /jcr:root/content//*[ <at> d_price > 50.0]

(Continue reading)

Alex Parvulescu (JIRA | 20 Jun 2012 16:18
Picon
Favicon

[Commented] (JCR-3347) Searches on properties of type Decimal give unexpected results


    [
https://issues.apache.org/jira/browse/JCR-3347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397535#comment-13397535
] 

Alex Parvulescu commented on JCR-3347:
--------------------------------------

I've commited a test using SQL2 and casts to Decimal values, for reference with revision 1352121.

FYI, if you plan on using Decimal values, use SQL2, as Xpath and SQL don't really have full support for that
data type.

> Searches on properties of type Decimal give unexpected results
> --------------------------------------------------------------
>
>                 Key: JCR-3347
>                 URL: https://issues.apache.org/jira/browse/JCR-3347
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>            Reporter: Felix Oghină
>            Assignee: Jukka Zitting
>
> Example:
> * have a node with a Decimal property, e.g. price=25
> * The following XPath query returns the node, although it shouldn't:
> /jcr:root/content//*[ <at> d_price > 50.0]

--
This message is automatically generated by JIRA.
(Continue reading)

Alexander Klimetschek (JIRA | 20 Jun 2012 16:47
Picon
Favicon

[Commented] (JCR-3347) Searches on properties of type Decimal give unexpected results


    [
https://issues.apache.org/jira/browse/JCR-3347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397553#comment-13397553
] 

Alexander Klimetschek commented on JCR-3347:
--------------------------------------------

> FYI, if you plan on using Decimal values, use SQL2, as Xpath and SQL don't really have full support for that
data type.

If the effort isn't too high, I would opt for implementing it using the double representation (50.0) for
xpath & sql. Seems intuitive to me. WDYT?

> Searches on properties of type Decimal give unexpected results
> --------------------------------------------------------------
>
>                 Key: JCR-3347
>                 URL: https://issues.apache.org/jira/browse/JCR-3347
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>            Reporter: Felix Oghină
>            Assignee: Jukka Zitting
>
> Example:
> * have a node with a Decimal property, e.g. price=25
> * The following XPath query returns the node, although it shouldn't:
> /jcr:root/content//*[ <at> d_price > 50.0]

--
(Continue reading)


Gmane