Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-5277

OData4 translator doesn't correctly translate LOCATE function to INDEXOF

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 8.12.11.6_4
    • Fix Version/s: 10.0.4, 10.2, 10.1.2
    • Component/s: OData
    • Labels:
      None

      Description

      Suppose this query against an OData4-backed view:

      SELECT STRINGKEY FROM BQT1.SmallA WHERE LOCATE('1', stringkey) = 1
      

      The WHERE clause gets translated into

      filter=indexof('1',stringkey) eq 1
      

      There are two issues with this:

      • the arguments of the indexof function should be in the opposite order (the sought-after string goes second)
      • indexof function indexes characters in strings from 0 whereas LOCATE from 1, this needs to be taken into account

      The correct filter in this case should be:

      filter=indexof(stringkey,'1') eq 0
      

      See http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html#startswithurl5.1.2.4.3

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                shawkins Steven Hawkins
                Reporter:
                jmartisk Jan Martiska
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: