feat(model): add advisory locks and SELECT FOR UPDATE#2103
Merged
Conversation
Adds database-level advisory locking and pessimistic row locking to close a gap vs Rails/Laravel/Django. Advisory locks coordinate exclusive access to shared resources without locking rows/tables. FOR UPDATE enables pessimistic row locking within transactions via the QueryBuilder. New files: - vendor/wheels/model/locking.cfc: withAdvisoryLock() mixin - vendor/wheels/tests/specs/model/lockingSpec.cfc: BDD tests Modified: - QueryBuilder.cfc: forUpdate() chain method - read.cfc: $forUpdate argument for findAll() - Base.cfc: stub methods with sensible defaults - All 7 database adapters: per-DB implementations Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PostgreSQL, MySQL, and SQL Server adapters were interpolating the
lock name directly into SQL strings, creating an injection vector
when the name comes from a non-trusted source. Switch to queryExecute
with bind parameters. Adds regression test using a name with single
quotes ("O'Brien's lock") that would have broken the old SQL.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f21a2b0 to
5e38c26
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
withAdvisoryLock(name, timeout, callback)class-level method on models for database advisory locking with automatic release via try/finallyforUpdate()chainable method on QueryBuilder for pessimistic row locking (SELECT ... FOR UPDATE)$forUpdateargument tofindAll()for direct use without QueryBuilderTest plan
🤖 Generated with Claude Code