Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Extra id field is saved with MongoDB GORM plugin  #2

@kapokfly

Description

@kapokfly

Using mongodb plugin 1.0M4 from http://grails.org/plugin/mongodb

Grails 1.3.7

Test Domain Class:
package com.test

import org.bson.types.ObjectId

class Person {
static mapWith = "mongo"

ObjectId id
String name

// Address address
// static embedded = ['address']
// static hasMany = [pets: Pet]

static mapping = {
name index: true, indexAttributes: [unique: true, dropDups: true]
//writeConcern WriteConcern.FSYNC_SAFE
// collection "mycollection"
// database "mydb"
// firstName field:"first_name"
}

static constraints = {
}
}

Create a new person and save it, no issue.
Edit the just created person, click update, go to mongodb shell, observe duplicate id fields present for the person instance.
In db:
{ "_id" : ObjectId("4d73a087f3f930d606e3c5b5"), "name" : "my name", "id" : ObjectId("4d73a087f3f930d606e3c5b5") }

Expected:
{ "_id" : ObjectId("4d73a087f3f930d606e3c5b5"), "name" : "my name"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions