-
Notifications
You must be signed in to change notification settings - Fork 199
Description
Original Reporter: oct
Environment: Fedora linux, Mongodb 1.6.4, Grails 1.3.7, mongodb M4
Version: Not Specified
Migrated From: http://jira.grails.org/browse/GPMONGODB-15
If domain's id is of type String, delete doesn't work properly, it ignores String type and assumes it's ObjectId
In both cases mongodb will execute (note _id is ObjectId):
{code}
{ "ts" : "Tue Feb 22 2011 23:28:26 GMT-0600 (CST)",
"info" : "remove query: { _id: ObjectId('4d649afa85632ecab2628ec2') }",
"millis" : 0 }
{code}
expected would be (for String version):
{code}
{ "ts" : "Tue Feb 22 2011 23:28:26 GMT-0600 (CST)",
"info" : "remove query: { _id: "4d649afa85632ecab2628ec2"}",
"millis" : 0 }
{code}
For example if we have these 2 domains:
{code}
class Book {
ObjectId id
String title
static constraints = { title blank:false }
}
{code}
{code}
class BookWithStringId {
String id
String title
static constraints = { title blank:false }
}
{code}
{code}
def b = Book.get(id)
b.delete() // works
def b2 = BookWithStringId.get(id)
b2.delete() // doesn't work
{code}
Please see attached a sample project. With 1 integration test.
PS: To see what mongodb does you may want to enable profiling (e.g. db.setProfilingLevel(2) )