borinquenkid opened a new issue, #16746:
URL: https://github.com/apache/grails-core/issues/16746

   ## Problem
   
   The code that chooses how a unique key is built or read for a nullable key 
treats DB2 like H2, PostgreSQL, MySQL, MariaDB and SQL Server: a row with a 
null in the key never conflicts. That is not verified for DB2 and may be wrong.
   
   Hibernate creates DB2's unique key as `create unique index ... exclude null 
keys` (`DB2Dialect#getCreateIndexTail`; `AlterTableUniqueIndexDelegate` says 
DB2 does not allow unique constraints on nullable columns). As far as I know, 
`exclude null keys` leaves out an entry only when all of its key columns are 
null, and DB2 compares the other nulls as equal, so `('en', null)` twice would 
conflict, as on Oracle. Nobody has run this on DB2.
   
   ## Where the assumption is made
   
   - `UniqueIndexNulls` (#16701): maps only `OracleDialect` to `COMPARED`, 
every other dialect, DB2 included, to `DISTINCT`. `SharedJoinTableUniqueness` 
builds one unique key per association for `DISTINCT`. On DB2, if nulls are 
compared, two associations that share a key column, or owners that share an 
element, would be rejected on legitimate rows.
   - `UniqueNullsPerDialect` for Hibernate 5 and 7 (#16583, issue #14503): DB2 
reads `skip`. If DB2 compares a partly null key, `database` should read `value` 
there, and the DB2 row of the table in `unique.adoc` and in the Grails 9 
upgrade note is wrong.
   
   ## What is needed
   
   1. A DB2 container spec (Testcontainers `db2` module, 
`icr.io/db2_community/db2`) added to the database matrix of 
`SharedJoinTableHibernate7Spec`, `SharedKeyColumnHibernate7Spec` and 
`UniqueNullsHibernate7Spec`, so the behavior is measured and not read from the 
source.
   2. If DB2 compares partly null keys, give it the `COMPARED` / `value` 
reading, with the DDL in `SharedJoinTableUniqueKeyBinderSpec` adjusted, and 
correct the documentation tables.
   3. Say in the documentation which databases the tests cover.
   
   The unit-level DDL specs only show the DDL Hibernate renders. They do not 
show how DB2 treats the index.
   


-- 
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]

Reply via email to