t31321
t31321

Reputation: 773

Specifying grails floating point precision in domain object constraint, how?

I how do I say a field is of the following type and precision in grails constraint?

FLOAT(7,4)

In mysql it means it will have value of something like xxx.yyyy, 3 decimal places to the left of dot and four decimal places to the right of the dot.

Upvotes: 1

Views: 1276

Answers (1)

Joshua Moore
Joshua Moore

Reputation: 24776

Set the max and scale constraints of your domain class property to influence the schema generation. The Grails documentation explains this in detail.

From the documentation:

someFloatValue max: 1000000, scale: 3

would yield:

someFloatValue DECIMAL(19, 3) // precision is default

Note The above is directly from the Grails documentation but logically it should yield DECIMAL(9, 3).

Upvotes: 1

Related Questions