HHH-18657 Use IF EXISTS in OracleUserDefinedTypeExporter

This commit is contained in:
Philippe Marschall 2024-09-22 19:48:00 +02:00 committed by Christian Beikov
parent c2728308b5
commit 7ffd991b80
1 changed files with 40 additions and 20 deletions

View File

@ -283,32 +283,52 @@ public class OracleUserDefinedTypeExporter extends StandardUserDefinedTypeExport
final Integer arraySqlTypeCode = userDefinedType.getArraySqlTypeCode(); final Integer arraySqlTypeCode = userDefinedType.getArraySqlTypeCode();
if ( arraySqlTypeCode == null || arraySqlTypeCode == TABLE ) { if ( arraySqlTypeCode == null || arraySqlTypeCode == TABLE ) {
return new String[] { return new String[] {
"drop type " + arrayTypeName + " force" buildDropTypeSqlString(arrayTypeName)
}; };
} }
return new String[] { return new String[] {
"drop type " + arrayTypeName + " force", buildDropTypeSqlString(arrayTypeName),
"drop function " + arrayTypeName + "_cmp", buildDropFunctionSqlString(arrayTypeName + "_cmp"),
"drop function " + arrayTypeName + "_distinct", buildDropFunctionSqlString(arrayTypeName + "_distinct"),
"drop function " + arrayTypeName + "_position", buildDropFunctionSqlString(arrayTypeName + "_position"),
"drop function " + arrayTypeName + "_length", buildDropFunctionSqlString(arrayTypeName + "_length"),
"drop function " + arrayTypeName + "_concat", buildDropFunctionSqlString(arrayTypeName + "_concat"),
"drop function " + arrayTypeName + "_includes", buildDropFunctionSqlString(arrayTypeName + "_includes"),
"drop function " + arrayTypeName + "_intersects", buildDropFunctionSqlString(arrayTypeName + "_intersects"),
"drop function " + arrayTypeName + "_get", buildDropFunctionSqlString(arrayTypeName + "_get"),
"drop function " + arrayTypeName + "_set", buildDropFunctionSqlString(arrayTypeName + "_set"),
"drop function " + arrayTypeName + "_remove", buildDropFunctionSqlString(arrayTypeName + "_remove"),
"drop function " + arrayTypeName + "_remove_index", buildDropFunctionSqlString(arrayTypeName + "_remove_index"),
"drop function " + arrayTypeName + "_slice", buildDropFunctionSqlString(arrayTypeName + "_slice"),
"drop function " + arrayTypeName + "_replace", buildDropFunctionSqlString(arrayTypeName + "_replace"),
"drop function " + arrayTypeName + "_trim", buildDropFunctionSqlString(arrayTypeName + "_trim"),
"drop function " + arrayTypeName + "_fill", buildDropFunctionSqlString(arrayTypeName + "_fill"),
"drop function " + arrayTypeName + "_positions", buildDropFunctionSqlString(arrayTypeName + "_positions"),
"drop function " + arrayTypeName + "_to_string", buildDropFunctionSqlString(arrayTypeName + "_to_string"),
"drop function " + arrayTypeName + "_from_json" buildDropFunctionSqlString(arrayTypeName + "_from_json")
}; };
} }
private String buildDropTypeSqlString(String arrayTypeName) {
if ( dialect.supportsIfExistsBeforeTypeName() ) {
return "drop type if exists " + arrayTypeName + " force";
} else {
return "drop type " + arrayTypeName + " force";
}
}
private String buildDropFunctionSqlString(String functionTypeName) {
if ( supportsIfExistsBeforeFunctionName() ) {
return "drop function if exists " + functionTypeName;
} else {
return "drop function " + functionTypeName;
}
}
private boolean supportsIfExistsBeforeFunctionName() {
return dialect.getVersion().isSameOrAfter( 23 );
}
private String determineValueExpression(String expression, int elementSqlTypeCode, String elementType) { private String determineValueExpression(String expression, int elementSqlTypeCode, String elementType) {
switch ( elementSqlTypeCode ) { switch ( elementSqlTypeCode ) {
case BOOLEAN: case BOOLEAN: