-
Notifications
You must be signed in to change notification settings - Fork 199
Description
Original Reporter: joshmandel
Environment: Grails 2.2.4
Version: 1.3.0.GA
Migrated From: http://jira.grails.org/browse/GPMONGODB-315
Forgive me if this is somehow expected behavior -- but I can't figure it out.
I'm seeing this behavior in my controllers in a simple grails app; though to reproduce it in an integration test I had to set:
static transactional = false
Basically, creating a new Value() and accessing a dynamic property causes the value to be persisted to the datastore, even without calling save():
def v = new Value()
assert Value.collection.find().count() == 0
Value.count()
assert Value.collection.find().count() == 0
v.accessingDynamicProperty = 'should not trigger a save'
assert Value.collection.find().count() == 0
Value.count()
assert Value.collection.find().count() == 0
Interestingly (to me), the saving appears to occur (in this integration test) as a side effect of calling Value.count() That is, if I leave out the Value.count() statements, this test will pass.
(In my actual grails app, the controller that creates this object doesn't call count(); it just creates a new object, sets a dynamic property, and renders a response.)
The attached .zip has a full test case that demonstrates the behavior.