Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-406

Java driver does not accept empty keys

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.6.4
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      linux / java 6

      which are perfect valid if using the shell:
      > db.po.insert(

      {"":1}

      );
      > db.po.insert(

      {"":2}

      );
      > db.po.find(

      {"":1}

      );

      { "_id" : ObjectId("4e3940ff933089c859e4d4f9"), "" : 1 }

      error source:
      private void _checkKeys( DBObject o ) {
      for ( String s : o.keySet() ){
      if ( s.contains( "." ) )
      throw new IllegalArgumentException( "fields stored in
      the db can't have . in them" );
      if ( s.charAt( 0 ) == '$' )
      throw new IllegalArgumentException( "fields stored in
      the db can't start with '$'" );
      Object inner;
      if ( (inner = o.get( s )) instanceof DBObject )

      { _checkKeys( (DBObject)inner ); }


      }
      }

      if ( s.charAt( 0 ) == '$' )
      should be:
      if (s.startWith('$' ))

            Assignee:
            antoine Antoine Girbal
            Reporter:
            rmuller Ronald K. Muller
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: