[openstreetmap/openstreetmap-website] Avoid using _id in queries (PR #4209)

Andy Allan notifications at github.com
Wed Aug 30 16:24:34 UTC 2023


This PR refactors some database queries, to avoid using `_id` and use the relation names instead. Generally this involves changing `.where(user_id => u.id)` to `.where(user => u)` or similar. Sometimes the relation name is quite different from the underlying column (e.g. `gpx_id` => `trace`).

Rails is pretty forgiving on whether you pass in an id or an object, so sometimes there's nothing to change on the right hand side.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/4209

-- Commit Summary --

  * Avoid using _id in queries
  * Use trace instead of gpx_id in queries

-- File Changes --

    M app/controllers/api/changesets_controller.rb (2)
    M app/controllers/api/notes_controller.rb (2)
    M app/controllers/changesets_controller.rb (6)
    M app/controllers/diary_entries_controller.rb (4)
    M app/controllers/issues_controller.rb (2)
    M app/controllers/user_roles_controller.rb (2)
    M app/models/changeset.rb (2)
    M app/models/trace.rb (10)
    M test/controllers/diary_entries_controller_test.rb (6)
    M test/models/trace_test.rb (6)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/4209.patch
https://github.com/openstreetmap/openstreetmap-website/pull/4209.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4209
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4209 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20230830/0389b4b8/attachment.htm>


More information about the rails-dev mailing list