Skip to content

Remove unnecessary ORDER BY clause when updating todos

What does this MR do?

Remove unnecessary ORDER BY clause when updating todos:

-- original (single item)

UPDATE "todos"
SET "state" = 'pending'
WHERE "todos"."id" IN
    (SELECT "todos"."id"
     FROM "todos"
     WHERE "todos"."user_id" = $1
       AND "todos"."id" = 229
       AND ("todos"."state" != $2)
     ORDER BY "todos"."id" DESC)

-- updated (single item)

UPDATE "todos"
SET "state" = 'pending'
WHERE "todos"."user_id" = $1
  AND "todos"."id" = 229
  AND ("todos"."state" != $2)

-- original (all items)

UPDATE "todos"
SET "state" = 'done'
WHERE "todos"."id" IN
    (SELECT "todos"."id"
     FROM "todos"
     WHERE "todos"."user_id" = $1
     AND "todos"."id" IN (228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218,
                             217, 216, 215, 214, 213, 212, 211, 210, 209, 188, 187,
                             186, 185, 184, 183, 182, 181, 180)
       AND ("todos"."state" != $2)
     ORDER BY "todos"."id" DESC)

-- updated (all items)

UPDATE "todos"
SET "state" = 'done'
WHERE "todos"."user_id" = $1
  AND "todos"."id" IN (228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218,
                          217, 216, 215, 214, 213, 212, 211, 210, 209, 188, 187,
                          186, 185, 184, 183, 182, 181, 180)
  AND ("todos"."state" != $2)

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Merge request reports