JetBrains / Exposed

Kotlin SQL Framework
http://jetbrains.github.io/Exposed/
Apache License 2.0
8.05k stars 676 forks source link

fix: EXPOSED-299 [H2 modes] SchemaUtils drops and adds identical composite foreign key #2005

Closed bog-walk closed 4 months ago

bog-walk commented 4 months ago

Calling SchemaUtils.createMissingTablesAndColumns() on a table with a composite foreign key incorrectly produces 2 ALTER statements (to drop and add the same constraint) when testing on some H2 compatibility modes (Oracle and SQL Server).

This occurs because these H2 modes delegate to the respective dialects which have NO_ACTION stored as their default. But a foreign key sent to the H2 database with NO_ACTION is returned by the driver metadata as the equivalent RESTRICT, leading to a false constraint equality check.