[JAVA-1341] DBCollection drop method does not delete a collection Created: 02/Aug/14  Updated: 04/Aug/14  Resolved: 03/Aug/14

Status: Closed
Project: Java Driver
Component/s: API
Affects Version/s: 2.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: deepak vohra Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7
MongoDB 2.4.9
MongoDB Java driver 2.11.3



 Description   

The drop() method in DBCollection does not delete a collection.



 Comments   
Comment by deepak vohra [ 04/Aug/14 ]

But the collection has been dropped. In the following catalog is the document to add to coll.
coll.insert(catalog);

Comment by Jeffrey Yemin [ 04/Aug/14 ]

It determines it by its name.

Comment by deepak vohra [ 03/Aug/14 ]

Must be some reference to the deleted collection kept in the cache or how else is it determined which collection is being referenced? For example if a collection has been created in another application.

coll = db.createCollection("catalog", null);

And in a different application the collection is dropped.
coll = db.getCollection("catalog");
coll.drop();

And in the second application the collection is referenced after being dropped.
coll.insert(catalog);

How is determined which collection is being referred to? Or, is a reference kept to the dropped collection?

Comment by Jeffrey Yemin [ 03/Aug/14 ]

Oh, I see the confusion. See http://docs.mongodb.org/manual/reference/method/db.createCollection/#db.createCollection. It states that collections in MongoDB are created implicitly whenever you reference them. So in step 4, the collection is created again after you drop it in step 3.

Comment by deepak vohra [ 03/Aug/14 ]

Haven't tested with shell but in a Java application the collection is still available and only the documents get deleted.

To test:

1. Create a collection.
2. Add a document to the collection.
3. Delete the collection with drop().
4. Add a document to the collection, which is supposed to have been deleted. The document gets added.

Comment by Jeffrey Yemin [ 03/Aug/14 ]

Please re-open if you can demonstrate that the collection is not actually dropped.

Comment by Jeffrey Yemin [ 02/Aug/14 ]

I just tried it. Here's the shell output from before calling drop on collection named foo:

> show collections
foo
system.indexes

and here it is from after:

> show collections
>

What do you see that makes you think it's not?

Comment by deepak vohra [ 02/Aug/14 ]

The drop() method just deletes the documents in the collection but does not delete the collection. Shouldn't the drop() method delete the collection?

Generated at Thu Feb 08 08:54:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.