grails / grails-views

Additional View Technologies for Grails
Apache License 2.0
56 stars 42 forks source link

First Item In Rendered List is not de-proxied #363

Open davymitchell opened 2 years ago

davymitchell commented 2 years ago

Experiencing an odd bug rendering a JSON list as part of a Rest API.

I am finding if the list of DO's contains a proxy object as the first item of a list, the view renders it as 'null' other proxy objects are rendered as expected.

If the first item is not a proxy, then all objects are rendered as expected.

My workaround is to do something like this: if (items.size() > 0) { items[0] = GrailsHibernateUtil.unwrapIfProxy(items[0]) as DO) } But this doesn't seem like a great or scalable solution.

Grails 4.0.13 Views-json 2.0.4

davymitchell commented 2 years ago

I have also noticed that the automatic de-proxying is not always accurate. For example if item 8 of a list of ten is proxied, then it will be populated with the contents of item 7. This has let me to deproxy the entire list always which feels like something the framework should take care of.