Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-195

Add "CAST" query operator

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • Sisyphus
    • None
    • API
    • Security Level: Public

    Description

      https://github.com/couchbase/couchbase-lite-core/issues/630

      We should have a query operator to cast a value to a type (at least to string or numeric.) There are situations where you need to convert two values to the same type to compare them, for example (as in this forum post) a join where one property is a number and the other a numeric string.

      The SQLite syntax is CAST(expr AS type), where type is a SQL column type, as in this list. The resulting affinity will be text, numeric, integer, real, or blob. I suggest we make our JSON syntax ["CAST", type, value] where type is an affinity name as a string literal.

      There are some workarounds, that use operators that typecast their operands:

      (x + 0) will convert x to a number
      (x || '') will convert x to a string

      Attachments

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

        Activity

          People

            The Lite The Lite
            jimb Jim Borden
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty