Uploaded image for project: 'Couchbase node.js Client Library'
  1. Couchbase node.js Client Library
  2. JSCBC-1092

Default query option of adhoc false is problematic

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • 4.1.2
    • 4.1.1
    • library
    • 1

    Description

      Since upgrading from the 3.x to 4.x Node SDK, the default for running queries is now

      {adhoc: false}

      . I'm not sure if this change was intentional or not, but it does cause anyone upgrading who runs "EXPLAIN" queries to fail at runtime as it attempts to EXPLAIN the EXPLAIN.

      I believe one of two solutions make sense:

      1. Return the default back to the 3.x default of { adhoc: true }

        . This may make sense because it is currently unnecessarily running prepares on many queries for which it may be unwarranted. That said, this change could be considered breaking, and also the original change may have been intentional in the 4.x series.

      2. When defaulting the "adhoc" option, use a regex to see if the query being run starts with "EXPLAIN". Something like {{ /\s*EXPLAIN\s/i}} should do the trick. If present, in that case only default adhoc to true. So perhaps adhoc: options.adhoc !== undefined ? !!adhoc : /\s*EXPLAIN\s/i.test(query),

      https://github.com/couchbase/couchnode/blob/bb15e938d1332a82595a7acbed048ea6b41691ad/lib/queryexecutor.ts#L133

      Note that this also may relate to this bug I found where prepared ALTER INDEX queries don't behave as expected: https://issues.couchbase.com/browse/MB-53264

      Attachments

        Activity

          People

            brett19 Brett Lawson
            btburnett3 Brant Burnett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty