Skip to content

Commit 49de011

Browse files
authored
fix: Migrations - add operator parameter to test_definition for custom SQL queries in MySQL and Postgres (#21044)
1 parent 5849606 commit 49de011

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
UPDATE test_definition
2+
SET json = JSON_ARRAY_INSERT(
3+
json,
4+
'$.parameterDefinition[2]',
5+
JSON_OBJECT(
6+
'name', 'operator',
7+
'displayName', 'Operator',
8+
'description', 'Operator to use to compare the result of the custom SQL query to the threshold.',
9+
'dataType', 'STRING',
10+
'required', false,
11+
'optionValues', JSON_ARRAY('==', '>', '>=', '<', '<=', '!=')
12+
)
13+
)
14+
WHERE NOT JSON_CONTAINS(
15+
JSON_EXTRACT(json, '$.parameterDefinition[*].name'),
16+
JSON_QUOTE('operator')
17+
) AND name = 'tableCustomSQLQuery';
18+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
UPDATE test_definition
2+
SET
3+
json = jsonb_insert(
4+
json,
5+
'{parameterDefinition, 2}',
6+
jsonb_build_object(
7+
'name', 'operator',
8+
'displayName', 'Operator',
9+
'description', 'Operator to use to compare the result of the custom SQL query to the threshold.',
10+
'dataType', 'STRING',
11+
'required', false,
12+
'optionValues', jsonb_build_array('==', '>', '>=', '<', '<=', '!=')
13+
)
14+
)
15+
WHERE
16+
name = 'tableCustomSQLQuery'
17+
AND NOT jsonb_path_exists(
18+
json,
19+
'$.parameterDefinition[*] ? (@.name == "operator")'
20+
);

0 commit comments

Comments
 (0)