Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPMONGODB-349: Update is not working when properties of concrete class changed #127

Closed
graemerocher opened this issue Jan 31, 2014 · 0 comments

Comments

@graemerocher
Copy link
Member

Original Reporter: yuki-takei
Environment: Not Specified
Version: 1.3.3
Migrated From: http:https://jira.grails.org/browse/GPMONGODB-349

h6. Summary

Update is not working when these conditions are met:

  • Grails 2.3.5
  • Using some Controller
  • Modifing properties of concrete class

h6. Confirming success when using Grails 2.2.4 and integration test

unzip test-with-2.2.4

cd test-with-2.2.4

grails test-app -integration

two Person documents will be created and both of 'version' will be 'NumberLong(1)'

h6. Confirming success when using Grails 2.2.4 and console (modify the property of abstract class)

unzip test-with-2.2.4

cd test-with-2.2.4

grails run-app

access http:https://localhost:8080/test-with-2.2.4/console

execute the code below

{code:title=Script1|borderStyle=solid}
// def setup()
def setupPerson = new Person()
setupPerson.name = "Philip"
setupPerson.mail = "[email protected]"
setupPerson.save(flush: true)
{code}

execute the code below anew

{code:title=Script2|borderStyle=solid}
// setup:
Person person = Person.list().last()

def id = person.id
def versionBeforeSave = person.version

// when: "set the property of abstract class and save"
person.name = "Allen"
person.save(flush: true)

// then: "update successfully"
Person savedPerson = Person.get(id)
assert savedPerson.version != versionBeforeSave
assert savedPerson.name == "Allen"
{code}

h6. Confirming success when using Grails 2.2.4 and console (modify the property of concrete class)

unzip test-with-2.2.4

cd test-with-2.2.4

grails run-app

access http:https://localhost:8080/test-with-2.2.4/console

execute the code below

{code:title=Script1|borderStyle=solid}
// def setup()
def setupPerson = new Person()
setupPerson.name = "Philip"
setupPerson.mail = "[email protected]"
setupPerson.save(flush: true)
{code}

execute the code below anew

{code:title=Script2|borderStyle=solid}
// setup:
Person person = Person.list().last()

def id = person.id
def versionBeforeSave = person.version

// when: "set the property of concrete class and save"
person.mail = "[email protected]"
person.save(flush: true)

// then: "update successfully"
Person savedPerson = Person.get(id)
assert savedPerson.version != versionBeforeSave
assert savedPerson.mail == "[email protected]"
{code}

h6. Confirming success when using Grails 2.3.5 and integration test

unzip test-with-2.3.5

cd test-with-2.3.5

grails test-app -integration

two Person documents will be created and both of 'version' will be 'NumberLong(1)'

h6. Confirming success when using Grails 2.3.5 and console (modify the property of abstract class)

unzip test-with-2.3.5

cd test-with-2.3.5

grails run-app

access http:https://localhost:8080/test-with-2.3.5/console

execute the code below

{code:title=Script1|borderStyle=solid}
// def setup()
def setupPerson = new Person()
setupPerson.name = "Philip"
setupPerson.mail = "[email protected]"
setupPerson.save(flush: true)
{code}

execute the code below anew

{code:title=Script2|borderStyle=solid}
// setup:
Person person = Person.list().last()

def id = person.id
def versionBeforeSave = person.version

// when: "set the property of abstract class and save"
person.name = "Allen"
person.save(flush: true)

// then: "update successfully"
Person savedPerson = Person.get(id)
assert savedPerson.version != versionBeforeSave
assert savedPerson.name == "Allen"
{code}

h6. NOT WORK when using Grails 2.3.5 and console (modify the property of concrete class)

unzip test-with-2.3.5

cd test-with-2.3.5

grails run-app

access http:https://localhost:8080/test-with-2.3.5/console

execute the code below

{code:title=Script1|borderStyle=solid}
// def setup()
def setupPerson = new Person()
setupPerson.name = "Philip"
setupPerson.mail = "[email protected]"
setupPerson.save(flush: true)
{code}

execute the code below anew

{code:title=Script2|borderStyle=solid}
// setup:
Person person = Person.list().last()

def id = person.id
def versionBeforeSave = person.version

// when: "set the property of concrete class and save"
person.mail = "[email protected]"
person.save(flush: true)

// then: "FAIL TO ASSERT"
Person savedPerson = Person.get(id)
assert savedPerson.version != versionBeforeSave
assert savedPerson.mail == "[email protected]"
{code}

The property 'mail' will not update and fail to assert because the object is not marked dirty.
If you modify properties of abstract class at the same time, it will be work fine.

Is it duplication of [GPMONGODB-334|http:https://jira.grails.org/browse/GPMONGODB-334]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant