<div style="display: flex; flex-wrap: wrap; white-space: pre-wrap; align-items: center; "><img height="20" width="20" style="border-radius:50%; margin-right: 4px;" decoding="async" src="https://avatars.githubusercontent.com/u/360803?s=20&v=4" /><strong>gravitystorm</strong> left a comment <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6379#issuecomment-3382454762">(openstreetmap/openstreetmap-website#6379)</a></div>
<p dir="auto">I'm not very good with database locks, but I have two questions:</p>
<div class="highlight highlight-source-ruby" dir="auto"><pre class="notranslate"><span class="pl-s1">changeset</span> <span class="pl-c1">=</span> <span class="pl-v">Changeset</span><span class="pl-kos">.</span><span class="pl-en">lock</span><span class="pl-kos">.</span><span class="pl-en">find</span><span class="pl-kos">(</span><span class="pl-en">params</span><span class="pl-kos">[</span><span class="pl-pds">:changeset_id</span><span class="pl-kos">]</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">Is this different from <code class="notranslate">changeset = Changeset.find(params[:changeset_id]).lock!</code> ? As far as I can tell from the docs, it's the same thing, but we use the <code class="notranslate">.lock!</code> variant elsewhere. If they are indeed identical, then I'd prefer to use the <code class="notranslate">.lock!</code> variant here, since that makes slightly easier to understand that it's the changeset being locked, and not e.g. the whole <code class="notranslate">Changeset</code> table.</p>
<p dir="auto">Second question, in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3364283367" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/6366" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/6366/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/pull/6366">#6366</a> the "safe navigation operator" was used, e.g. <code class="notranslate">node.changeset&.lock!</code>. I found that surprising, since taking a lock is generally not optional! Is this deliberate, or is it a side-effect of taking the lock too early on e.g. should the lock be taken after the code that validates the changeset exists? Or is there something else there about locks that I don't understand?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6379#issuecomment-3382454762">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLOYTKX6Z6QVZ5ZRLRL3WU7EFAVCNFSM6AAAAACFUYOU5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOBSGQ2TINZWGI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJ4A6YSPF4VVQ5T4DT3WU7EFA5CNFSM6AAAAACFUYOU5KWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTWJTQU6U.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/6379/c3382454762</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>

<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/6379#issuecomment-3382454762",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/6379#issuecomment-3382454762",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>