bp-FLN opened a new issue, #14517:
URL: https://github.com/apache/grails-core/issues/14517
While upgrading from grails 3.1.15 to 3.3.11 we noticed a regression on the
unique constraint.
More specifically, a multi-column unique constraint on the same domain class.
The Domain has a reference to itself and the identifier is supposed to be
unique between all children of the same parent.
```
class Domain {
String identifier
boolean is_parent
Domain parent
static constraints = {
identifier(nullable: true, blank: true, unique: 'parent')
parent(nullable: true)
}
}
```
We noticed that the query for the unique check is incomplete:
`select this_.id as y0_ from domain this_ where this_.identifier=? limit ?`
the parent is not even considered
This used to work in grails 3.1.15 which generates this query instead:
`select this_.id as id1_0_0_, this_.version as version2_0_0_,
this_.identifier as identifi3_0_0_, this_.is_parent as is_paren4_0_0_,
this_.parent_id as parent_i5_0_0_ from domain this_ where this_.identifier=?
and this_.parent_id=?`
The sample project has an integration test that showcases this.
### Task List
- [X] Steps to reproduce provided
- [ ] Stacktrace (if present) provided
- [X] Example that reproduces the problem uploaded to Github
- [X] Full description of the issue provided (see below)
### Steps to Reproduce
1. Clone the sample repo and run `DomainIntegrationTest`
2. last test fails
### Expected Behaviour
spec should not fail
### Actual Behaviour
spec fails - the unique constraint in the Domain class is not working as
expected
### Environment Information
- **Operating System**: MacOS 10.14.6
- **GORM Version:** 6.1.12.RELEASE
- **Grails Version (if using Grails):** 3.3.11
- **JDK Version:** openjdk version "1.8.0_232"
### Example Application
https://github.com/bp-FLN/uniqueConstraint/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]