borinquenkid commented on PR #16816:
URL: https://github.com/apache/grails-core/pull/16816#issuecomment-6576816513
**For the team: `!=` / `ne` and null rows**
This PR adds integration scenarios to
`grails-test-examples/hibernate5/grails-hibernate` and
`.../hibernate7/grails-hibernate`, the same spec on both. Running it showed
Hibernate 7 and Hibernate 5 disagreed on one thing:
- `where { age != 11 }`, `ne 'age', 11` and `countByAgeNotEqual(11)` leave
out rows where `age` is null on **Hibernate 5** (`Restrictions.ne`, plain SQL
`<>`).
- **Hibernate 7** included them (an `OR … IS NULL` added in the April
query-engine rewrite), so the same query returned different rows after an
upgrade.
781d0f355b makes H7 match H5. The H7 `NullValueEqualSpec` now carries the
same documented exception to the TCK that the H5 copy has.
**Why H5 is the reference, not the TCK line:** the TCK assertion
`countByAgeNotEqual(11) == 2` came in with grails-data-mapping
[#1220](https://github.com/apache/grails-data-mapping/pull/1220) (2019). It
never passed on Hibernate: Graeme [disabled it for
Hibernate](https://github.com/apache/grails-data-mapping/pull/1220#issuecomment-481605365)
as "not yet implemented", and a contributor noted that making `NotEqual`
null-inclusive "may break existing application code". The docs never promise
it. So Hibernate has always left null rows out of `!=`.
**Worth sharing with the team**
- Neo4j and the other datastores still count null rows, so the datastores
differ here. That was already true before this PR; I did not change it.
- `ne 'age', null` stays `IS NOT NULL` on H7, as the dynamic finder does
(`countByAgeNotEqual(null) == 1` on both). Only H5's criteria-builder path
turns it into `<> NULL`, which matches nothing.
- `!` / `not {}` already left null rows out on both.
Full `grails-data-hibernate7-core` suite: 4351 tests, 0 failures.
Integration spec: H5 38/38, H7 39/39.
--
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]