Skip to content

Commit

Permalink
Fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Clue committed Mar 18, 2024
1 parent 4c36d25 commit 3808ed7
Showing 1 changed file with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
// This query is returning tests that have any assertions that
// have a priority value of REQUIRED or OPTIONAL.
`
SELECT
SELECT
id,
tests
FROM
Expand All @@ -24,8 +24,7 @@ module.exports = {
WHERE
assertion ->> 'priority' = 'REQUIRED'
OR assertion ->> 'priority' = 'OPTIONAL'
),
id = ?`,
)`,
{
type: Sequelize.QueryTypes.SELECT,
transaction
Expand Down Expand Up @@ -61,21 +60,14 @@ module.exports = {
})
);
await queryInterface.sequelize.query(
`UPDATE
"TestPlanVersion"
SET
tests = ?
WHERE
EXISTS (
SELECT
1
FROM
jsonb_array_elements(tests) AS test,
jsonb_array_elements(test -> 'assertions') AS assertion
WHERE
assertion ->> 'priority' = 'REQUIRED'
OR assertion ->> 'priority' = 'OPTIONAL'
)`,
`
UPDATE
"TestPlanVersion"
SET
tests = ?
WHERE
id = ?
`,
{ replacements: [updatedTests, id], transaction }
);
})
Expand Down

0 comments on commit 3808ed7

Please sign in to comment.