Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-3218

CBL 2.0 where expression clarification

    XMLWordPrintable

Details

    • DOC-S13-Apr06, DOC-S14-Apr13[Vulcan Beta]

    Description

      From GitHub: https://github.com/couchbase/couchbase-lite-core/issues/392

      Interpreting strings as booleans is weird. Most strings are false, but strings with nonzero numeric prefixes – in this case "2willowroad@nationaltrust.org.uk" -- are true.

      Evaluating Expression.property("email").and(...) involves interpreting a string as a boolean. SQLite has no boolean type, just numbers, so it tries to parse the string as a number. Its number parser just stops when it reaches an illegal numeric character, returning whatever came before it, or zero if there were no digits. So "2willow" evaluates to 2, which is true.

      This is counter-intuitive to be sure. But to change the way this works would require writing our own C function to do the conversion, and making our SQL query generator wrap it around every single expression that gets interpreted as a boolean. This would probably slow down queries; I don't know by how much.

      Attachments

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

        Activity

          People

            jamiltz James Nocentini
            daniel.petersen Daniel Petersen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty