grails-data-mapping icon indicating copy to clipboard operation
grails-data-mapping copied to clipboard

For Enum field in domain class, maxSize cannot be applied in migration

Open keitaroemotion opened this issue 4 years ago • 0 comments

I am now trying to make migration in Grails, and here is my domain class:

class SomeDomain {
    String    stringField
    EnumClass enumField
    static constraints = {
        stringField nullable: true, maxSize: 100
        enumField   nullable: true, maxSize: 100    
    }
}

then if I auto generated diff groovy file,

It reflects the stringField's maxSize(100), but for enumField there are no constraints reflected such that it is of maxSize(255).

Task List

  • [ ] Steps to reproduce provided
  • [ ] Stacktrace (if present) provided
  • [ ] Example that reproduces the problem uploaded to Github
  • [ ] Full description of the issue provided (see below)

Steps to Reproduce

  1. make domain class with enum field.
  2. make constraints for the enum field with maxSize: 100
  3. auto generate migration file according to 2. then you see maxSize(100) is not applied and its size is VARVHAR(255). (mySQL5.6)

Expected Behaviour

After the migration, the fields constraints should be 100.

Actual Behaviour

the fields constraints are size of 255

Environment Information

  • Operating System: Amazon linux
  • GORM Version: TODO
  • Grails Version (if using Grails): | Grails Version: 3.2.13 | Groovy Version: 2.4.15 | JVM Version: 1.8.0_272 openjdk version "1.8.0_272" OpenJDK Runtime Environment (build 1.8.0_272-b10) OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)

Example Application

  • TODO: link to github repository with example that reproduces the issue

keitaroemotion avatar Feb 06 '21 13:02 keitaroemotion