Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-61025

numericOrdering produce incorrect query results

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 4.4.0, 5.0.0
    • None
    • ALL
    • Hide

      db.createCollection('numericOrderingError', { collation: {locale: 'en_US', numericOrdering: true} });
      db.getCollection('numericOrderingError').insertMany([
        {"clientCode" : "A0001"},
        {"clientCode" : "A1"}
      ])
      db.getCollection('numericOrderingError').find({"clientCode": "A0001"})
      

       

      Output: A0001 and A1

      Expected: A0001

      Show
      db.createCollection( 'numericOrderingError' , { collation: {locale: 'en_US' , numericOrdering: true } }); db.getCollection( 'numericOrderingError' ).insertMany([ { "clientCode" : "A0001" }, { "clientCode" : "A1" } ]) db.getCollection( 'numericOrderingError' ).find({ "clientCode" : "A0001" })   Output: A0001 and A1 Expected: A0001

    Description

      In collections with collation and "numericOrdering = true" the query results are incorrect when the search string includes zeros, leading zeros are ignored.
      According to the documentation, the numericOrdering option should only affect the comparison of numeric text strings (in the example "clientCode" includes letters)

      Attachments

        Activity

          People

            edwin.zhou@mongodb.com Edwin Zhou
            german.pedrosa@ekon.es Germán Pedrosa
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: