override fun resolveReferenceOption()

in exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/statements/jdbc/JdbcDatabaseMetadataImpl.kt [521:544]


    override fun resolveReferenceOption(refOption: String): ReferenceOption? {
        val dialect = currentDialect

        // MySQL/MariaDB use custom query that returns string-name values
        if (dialect is MysqlDialect) {
            return ReferenceOption.valueOf(refOption.replace(" ", "_"))
        }

        val refOptionInt = refOption.toIntOrNull() ?: return null

        return when (refOptionInt) {
            DatabaseMetaData.importedKeyCascade -> ReferenceOption.CASCADE
            DatabaseMetaData.importedKeyRestrict -> {
                val restrictNotSupported = dialect is OracleDialect ||
                    dialect.h2Mode == H2CompatibilityMode.Oracle ||
                    dialect.h2Mode == H2CompatibilityMode.SQLServer
                if (restrictNotSupported) ReferenceOption.NO_ACTION else ReferenceOption.RESTRICT
            }
            DatabaseMetaData.importedKeySetNull -> ReferenceOption.SET_NULL
            DatabaseMetaData.importedKeyNoAction -> ReferenceOption.NO_ACTION
            DatabaseMetaData.importedKeySetDefault -> ReferenceOption.SET_DEFAULT
            else -> currentDialect.defaultReferenceOption
        }
    }