Skip to content

Commit 4199be8

Browse files
author
Brendan W. McAdams
committed
JAVA-444: make ensureIndex first do a read on index collection to see if index exists
* If an embedded field was referenced in an index a hard failure occurred, due to triggering of the 'no dots in key names' logic via the insert. Moved code to use the lower level API method which permits disabling of key checks.
1 parent d3fb5f9 commit 4199be8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/com/mongodb/DBApiLayer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ public void createIndex( final DBObject keys, final DBObject options, DBEncoder
359359
full.put( k , options.get( k ) );
360360
full.put( "key" , keys );
361361

362-
DBCollection idxs = DBApiLayer.this.doGetCollection( "system.indexes" );
362+
MyCollection idxs = DBApiLayer.this.doGetCollection( "system.indexes" );
363363
//query first, maybe we should do an update w/upsert? -- need to test performance and lock behavior
364364
if ( idxs.findOne( full ) == null )
365-
idxs.insert( new DBObject[] { full }, WriteConcern.SAFE, encoder );
365+
idxs.insert( new DBObject[] { full }, false, WriteConcern.SAFE, encoder );
366366
}
367367

368368
final String _fullNameSpace;

0 commit comments

Comments
 (0)