tags:

views:

29

answers:

1

Question using Grails 1.3.4 - the 'scale' constraint does not seem to keep my decimals. I have a field defined as: Float latitude I have a constraint: latitude(blank: false, range:-360.0f..360.0f, scale:6) The Oracle 10g field is defined as: NUMBER(10,6)

When I enter a value in Create or Edit, the correct value gets to the database. However, it never displays correctly in Show. If I enter 10.1234567 and update, 10.123457 is in the database but 10.123 displays in Show.

If I Edit, the value shows as 10.123, and if I update without modifying it, 10.123 will be stored in the database, replacing 10.123457 even though I never touched that field.

If I edit the value to 10.456789, but leave another required field blank, the resulting Edit screen with the error message displays the value as 10.457.

Why is Grails continually rounding the value to 3 digits? I tried the field as a Double as well, but same results. I thought maybe it was Oracle, but I tried it with the default dev database, and same result. I thought maybe it was the 'range', but I took that off with the same result.

A: 

Hmm - are you sure it's displaying correctly in your database viewer? Also - check your use of tags: See http://www.pubbs.net/200908/grails/38057-grails-user-how-does-rounding-of-decimals-work-in-gsp.html

Joe C
Thanks for the link. Following the advice of that user worked. I removed the fieldValue tag and just displayed the value straight out ${bean.field} and got all 6 decimals
snowmanjack