For Enum field in domain class, maxSize cannot be applied in migration
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
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
Contributor guide
Research direction
Start with the SomeDomain enumField declaration and its maxSize constraint, then reproduce the auto-generated migration on MySQL 5.6 using the listed Grails 3.2.13 environment. Trace how the migration represents enum fields and compare it with stringField; done means the generated migration applies a length of 100 rather than VARCHAR(255).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100