kaleidos / grails-postgresql-extensions

Grails plugin to use postgresql native elements such as arrays, hstores,...
Apache License 2.0
78 stars 63 forks source link

getDirtyPropertyNames() returns all HstoreMapType fields, even if not dirty #96

Closed Taack closed 7 years ago

Taack commented 7 years ago
def beforeUpdate() {
        println id + " " + getDirtyPropertyNames()
}

prints all HstoreMapType fields, even if none has been updated.

I am using org.grails.plugins:postgresql-extensions:4.6.6 with Grails 3.1.6.

Thanks for your support, Adrien

ilopmar commented 7 years ago

Could you please create a sample application that reproduces the issue, upload to github and post here the link?

jglapa commented 7 years ago

I'm seeing the same problem also with the 4.x.x extension and Grails 3.2.6 and hibernate4. But I prepared an example with Grails 3.2.6, hibernate5 and plugin 5.x.x. Same thing. Here's the project https://github.com/jglapa/hstore-dirty-property

just run it and hit the http://localhost:8080/testDomain/index URL then observe the console. PS. you need to have a hstore_dirty_property database on localhost with user and password test

PS2. In my app I see even worse behaviour. For such cases when retrieving a domain object by simple get with empty hstore my optimisting locking version field gets incremented six times! But I suspect it has something to do with the audit-logging plugin which I'm using and this relies on the dirty checking...

ilopmar commented 7 years ago

I don't know the internals of how dirty checking works but in the plugin we don't do anything special to support it. Actually we never thought about it.

I haven't used postgres in a while and I don't have enough spare time at this moment so I'm afraid I won't be able to try to fix this. If you have some time and want to send a PR that fixes this I'll make a new release.

jglapa commented 7 years ago

hey @ilopmar I've submitted a PR https://github.com/kaleidos/grails-postgresql-extensions/pull/104 with short explanation.

ilopmar commented 7 years ago

Merged PR #104

ilopmar commented 7 years ago

Released version 5.0.1

ilopmar commented 7 years ago

Released also version4.6.9 with the backported changes to 4.x branch