Uploaded image for project: 'Couchbase Go SDK'
  1. Couchbase Go SDK
  2. GOCBC-1038

Named parameters not set in query v2.2.0

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not a Bug
    • Affects Version/s: 2.2.0
    • Fix Version/s: None
    • Component/s: library
    • Labels:
    • Environment:
      go 115.6
    • Story Points:
      1

      Description

      When running the following example code in the documents

      ```

      query := "SELECT x.* FROM `travel-sample` x WHERE x.`type`=$type LIMIT 10;"

      params := make(map[string]interface{}, 1)

      params["type"] = "hotel"

      rows, err := cluster.Query(query, &gocb.QueryOptions{NamedParameters: params})

      ```

      The `$type` parameter is not set in the query upon execution. 

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

          Hide
          lukekroon Luke added a comment -

          Thank you Charles Dixon, that solves the problem for now. Is there something that we are doing wrong on our side ? 

          Show
          lukekroon Luke added a comment - Thank you  Charles Dixon , that solves the problem for now. Is there something that we are doing wrong on our side ? 
          Hide
          charles.dixon Charles Dixon added a comment -

          I will look into it some more and let you know Luke, it looks ok to me but clearly something is going wrong somewhere.

          Show
          charles.dixon Charles Dixon added a comment - I will look into it some more and let you know Luke , it looks ok to me but clearly something is going wrong somewhere.
          Hide
          Sitaram.Vemulapalli Sitaram Vemulapalli added a comment - - edited

          The index is partial index (index has WHERE clause), But query passing the prepare statement with named parameter 

          javaClass = $type. This will not choose the index because runtime you can give different value $type = "xyz". This result in wrong results. 

           

          Adhoc=true means named parameter also part of statement, Query service will inline named/positional parameters before index selection.

           

          Solution: Change query `javaClass` = "com.**.*.**.Site" OR remove index WHERE clause.

          Show
          Sitaram.Vemulapalli Sitaram Vemulapalli added a comment - - edited The index is partial index (index has WHERE clause), But query passing the prepare statement with named parameter  javaClass = $type. This will not choose the index because runtime you can give different value $type = "xyz". This result in wrong results.    Adhoc=true means named parameter also part of statement, Query service will inline named/positional parameters before index selection.   Solution: Change query `javaClass` = "com.** . * . **.Site" OR remove index WHERE clause.
          Hide
          lukekroon Luke added a comment -

          Sitaram Vemulapalli thank you for the reply. That makes sense. 

          In this case the javaClass value will never change, so it makes sense then to change the query to  `javaClass` = "com.**.*.**.Site". 

          I should investigate the PREPARE statement further.

          Show
          lukekroon Luke added a comment - Sitaram Vemulapalli  thank you for the reply. That makes sense.  In this case the javaClass value will never change, so it makes sense then to change the query to  `javaClass` = "com.** . * . **.Site".  I should investigate the PREPARE statement further.
          Hide
          charles.dixon Charles Dixon added a comment -

          I'm resolving this as it seems to be not a bug and the problem also seems to be resolved. Please reopen if you disagree.

          Show
          charles.dixon Charles Dixon added a comment - I'm resolving this as it seems to be not a bug and the problem also seems to be resolved. Please reopen if you disagree.

            People

            Assignee:
            charles.dixon Charles Dixon
            Reporter:
            lukekroon Luke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes

                  PagerDuty