Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 22
    • Issues 22
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLab FOSSGitLab FOSS
  • Merge requests
  • !10399

Remove unnecessary ORDER BY clause when updating todos

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged M. Hasbini requested to merge 0xbsec/gitlab-ce:todo-update-order into master Apr 02, 2017
  • Overview 2
  • Commits 1
  • Pipelines 1
  • Changes 2

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?

  • Changelog entry added, if necessary
  • Documentation created/updated
  • API support added
  • Tests
    • Added for this feature/bug
    • All builds are passing
  • Conform by the merge request performance guides
  • Conform by the style guides
  • Branch has no merge conflicts with master (if it does - rebase it please)
  • Squashed related commits together

What are the relevant issue numbers?

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: todo-update-order