Identity length is not working with MappingBuilder.orm
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
### Task List
- [x] Steps to reproduce provided
- [ ] ~Stacktrace (if present) provided~
- [ ] ~Example that reproduces the problem uploaded to Github~
- [x] Full description of the issue provided (see below)
### Steps to Reproduce
1. Create a simple domain class.
2. Add the following mapping block-
```groovy
import grails.gorm.hibernate.mapping.MappingBuilder
class User {
String id
static mapping = MappingBuilder.orm {
id generator: "assigned", length: 20
// Tried below as well
// id generator: "assigned", maxLength: 20
// id generator: "assigned", params: [length: 20]
}
}
```
3. Run the app and check the table `desc user` in MySQL.
### Expected Behaviour
The `id` column should be created as `VARCHAR(20)`.
### Actual Behaviour
The `id` column is being created as `VARCHAR(255)`.
### Environment Information
- **Operating System**: macOS Catalina 10.15.7
- **GORM Version:** 7.0.6
- **Grails Version (if using Grails):** 4.0.4
- **JDK Version:** Oracle JDK 1.8.0_91
### Description
To use types and `@GrailsCompileStatic` annotation, I'm using `MappingBuilder.orm` in the `mapping` block.
https://stackoverflow.com/a/60118491/2405040
Contributor guide
Research direction
Start with the MappingBuilder.orm mapping block shown in the issue and reproduce it using the User domain class on GORM 7.0.6 and Grails 4.0.4. Inspect the generated MySQL schema with `desc user` and compare the id column with the expected VARCHAR(20). Done means the mapping produces the requested identity length instead of VARCHAR(255).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, mysql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100