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

_genIndexName might create duplicated "_" in a generated index name

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • 1.6.5
    • Shell
    • None
    • ALL

    Description

      DBCollection.prototype._genIndexName generates index name automatically if it is not supplied.
      It concatenates keys and direction. For example,

      {field1: 1, field2: -1, field3: 1}

      results with field1_1_field2_-1_field3_1
      If instead of direction with have a string (2d) we might have duplicate "" or unneeded "" at the end.
      Example 1:

      {field1: 1, field2: "2d"}

      "field1_1_field2_"

      Example2:

      {field1: 1, field2: "2d", field3: -1}

      "field1_1_field2_field3-1"

      It's not a big deal but other drivers might implement it in a different way
      and the duplicated "_" might cause a confusion.

      https://github.com/mongodb/mongo/blob/master/shell/collection.js#L218

      Fix:
      DBCollection.prototype._genIndexName = function( keys ){
      var name = "";
      for ( var k in keys )

      { var v = keys[k]; if ( typeof v == "function" ) continue; if ( name.length > 0 ) name += "_"; //name += k + "_"; // ------------- if ( typeof v == "number" ) //name += v; // --------------- name += "_" + v; // +++++++++ }

      return name;
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            pablo pablo platt
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: