Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-2181

Mixed type comparison rules

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • v1.3.10
    • None
    • manual
    • None

    Description

      I couldn't find any documentation on how mixed types compare in mongo queries. For example, if a document has

      { a: 1 }

      , does the query

      { a: NumberLong(1) }

      find it? I figured out by experiment that the type does not seem to matter, but would like some page to state the precise rules.

      E.g. what about $gt, $ne, etc.? Does a boolean/numeric comparison ever return true? How about string/numeric?

      Most of this is pretty straightforward and intuitive, but it needs to be specified somewhere.

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            andre.spiegel@mongodb.com Andre Spiegel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              9 years, 26 weeks, 1 day ago