Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2166

Allow cast of dynamic operand in queries

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • 4.5.0.Final
    • 4.0.0.Alpha2
    • Query
    • None

      Standard JCR-SQL2 only allows `CAST( ``value`` AS ``type`` )` on the right-hand side of a constraint. This is limiting, especially when the property value may contain a value that is convertible to another type and the constraint should be applied using that other type.

      For example, consider a node type with a property definition for `propertyY` that defines the type as a STRING. Even if some of those values contained string-representations of DOUBLE values, the following query could not be performed:

      SELECT * FROM [nodex] as x  where x.propertyY <= 20.50
      

      It would be nice to be able to do this:

      SELECT * FROM [nodex] as x  where CAST(x.propertyY AS DOUBLE) <= 20.50
      

      Doing this will require having a `DynamicOperand` subtype for the `CAST` operation, though the value in the cast probably only needs to be a `PropertyValue`. Specifically, something like this:

      DynamicOperand ::= PropertyValue | ReferenceValue |
                         Length | NodeName | NodeLocalName |
                         NodePath | NodeDepth |
                         CastPropertyValue |
                         FullTextSearchScore |
                         LowerCase | UpperCase |
                         Arithmetic |
                         '(' DynamicOperand ')'
      
      CastPropertyValue ::= 'CAST(' PropertyValue ' AS ' PropertyType ')'
      

      where `PropertyValue` and `PropertyType` are already defined in the grammar.

            hchiorean Horia Chiorean (Inactive)
            rhauch Randall Hauch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: