Repository navigation
Pass a res.locals object to the dbs connection from the query - #2973
AlexanderGeere wants to merge 6 commits into
Conversation
…module. The dbs module ignores options.req. A composing host which replaces a dbs connection can read the request context from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughDatabase query calls now pass query settings through one params object instead of positional arguments. The query module includes ChangesDatabase query params
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Merge Risk: ⚪ Minimal · up to This change moves database query settings into one params object and passes res.locals to the connection. The call sites and the consumer appear consistent, and no actionable merge-blocking risk remains. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Only the values a host sets for its dbs connections are passed, not the whole request. Clients cannot write to res.locals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I asked Claude to consolidate the individual params into a params object. This disolves the The benefits are: |
|
@coderabbitai review |
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
This makes sense to me, much more expandable going forward. |
|
@coderabbitai review |
|
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Description
Pass
res.localsto the dbs connection asoptions.localsThe query module now passes
res.localsto the dbs connection asoptions.locals:
{ locals }for a blocking query{ locals, nonblocking: true }for a nonblocking one.The dbs module only reads
options.nonblocking, sooptions.localsis ignored and nothing changes for the connections it creates.res.localswould be an object containing what the hosts db connection wants e.g{ dbs: {tenant_id: 7} }Why
A composing host can replace a connection in the
dbsmodule's exported object with its own function e.g. to run every query on that connection inside a transaction with settings taken from therequest.Its middleware puts the values that connection needs on
res.locals. Only that object is passed, not the whole request. Clients can't write tores.locals, unlikereq.params, which the query string is merged into.Tests check that the context reaches the connection for both blocking and nonblocking queries, and that the request isn't passed.
GitHub Issue
Type of Change
How have you tested this?
Ran the tests written here
Testing Checklist
Code Quality Checklist
Summary by CodeRabbit