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

numericOrdering produce incorrect query results

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.4.0, 5.0.0
    • Component/s: 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

      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)

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

              Created:
              Updated:
              Resolved: