mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-17 11:43:54 +00:00
migration: fix duplicate param key insertion (#20802)
This commit is contained in:
parent
1a6224824b
commit
98c6b6e4ef
@ -14,4 +14,5 @@ SET json = JSON_MERGE_PRESERVE(
|
||||
)
|
||||
)
|
||||
)
|
||||
WHERE name = 'tableDiff';
|
||||
WHERE name = 'tableDiff'
|
||||
AND NOT JSON_CONTAINS(json->>'$.parameterDefinition', JSON_OBJECT('name', 'caseSensitiveColumns'));
|
||||
|
@ -5,4 +5,9 @@ SET json = jsonb_set(
|
||||
(json->'parameterDefinition')::jsonb ||
|
||||
'{"name": "caseSensitiveColumns", "dataType": "BOOLEAN", "required": false, "description": "Use case sensitivity when comparing the columns.", "displayName": "Case sensitive columns"}'::jsonb
|
||||
)
|
||||
WHERE name = 'tableDiff';
|
||||
WHERE name = 'tableDiff'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM jsonb_array_elements(json#>'{parameterDefinition}') AS elem
|
||||
WHERE elem->>'name' = 'caseSensitiveColumns'
|
||||
);
|
||||
|
@ -37,9 +37,14 @@ public class MigrationUtil {
|
||||
TestDefinition td = getTestDefinition(daoCollection, testCase);
|
||||
if (Objects.nonNull(td) && Objects.equals(td.getName(), TABLE_DIFF)) {
|
||||
LOG.debug("Adding caseSensitiveColumns=true table diff test case: {}", testCase.getId());
|
||||
testCase
|
||||
.getParameterValues()
|
||||
.add(new TestCaseParameterValue().withName("caseSensitiveColumns").withValue("true"));
|
||||
if (!hasCaseSensitiveColumnsParam(testCase.getParameterValues())) {
|
||||
testCase
|
||||
.getParameterValues()
|
||||
.add(
|
||||
new TestCaseParameterValue()
|
||||
.withName("caseSensitiveColumns")
|
||||
.withValue("true"));
|
||||
}
|
||||
daoCollection.testCaseDAO().update(testCase);
|
||||
}
|
||||
}
|
||||
@ -60,4 +65,10 @@ public class MigrationUtil {
|
||||
}
|
||||
return dao.testDefinitionDAO().findEntityById(records.get(0).getId());
|
||||
}
|
||||
|
||||
private static boolean hasCaseSensitiveColumnsParam(
|
||||
List<TestCaseParameterValue> parameterValues) {
|
||||
return parameterValues.stream()
|
||||
.anyMatch(paramValue -> paramValue.getName().equals("caseSensitiveColumns"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user