feat: enable adhoc option for prepared statement plan caching#36
feat: enable adhoc option for prepared statement plan caching#36pimpin wants to merge 8 commits into
Conversation
… queries Add adhoc: false to N1ql.config default so every n1ql-macro query opts into Couchbase server-side plan caching. The value flows through the reverse_merge in the generated method, maintaining the same override priority as scan_consistency: per-call > per-definition > N1ql.config > default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tion queries Read adhoc from N1ql.config in build_query_options so all Relation-based queries (.where, .all, .first, .last, .ids, update_all, delete_all, etc.) also benefit from server-side plan caching without any caller changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces support for the adhoc query option (defaulting to false to enable prepared statement plan caching) across Couchbase ORM N1QL queries and relations, along with corresponding tests. The review feedback highlights a potential issue where custom configurations might omit the adhoc key, resulting in it resolving to nil and silently disabling plan caching; merging the custom configuration with the defaults is recommended to prevent this.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…verride Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Default adhoc to true to preserve original gem behavior (no prepared statement caching unless explicitly opted in). Use DEFAULT_ADHOC constant for consistency with DEFAULT_SCAN_CONSISTENCY. Fix config to merge thread-local overrides on top of defaults instead of replacing them. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduce `query_options(**opts)` on CouchbaseOrm_Relation that merges arbitrary Couchbase::Options::Query keyword args (scan_consistency, adhoc, timeout, etc.) into the query. `adhoc(value)` becomes a convenience wrapper over `query_options(adhoc: value)`, preserving the existing API. build_query_options now merges N1ql.config defaults with per-relation overrides, eliminating the nil-guard on @adhoc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pimpin
left a comment
There was a problem hiding this comment.
Some more fix todo.
Address review feedback: - Keep existing behaviour: default adhoc: true (opt into plan caching with adhoc: false), fix specs to reflect true as the default value - Remove the dedicated Relation#adhoc method and its delegate alias; the generic `with(adhoc:)` covers the per-query override - Update SQL++ docs to reflect the flipped default and `with` usage Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Expose the
adhocquery option so callers can opt into Couchbase server-side prepared-statement plan caching (adhoc: false), while preserving the existing default behaviour (adhoc: true, no caching).DEFAULT_ADHOC = trueand wireadhocintoN1ql.configso any customized config still falls back to the defaults (merge over{ scan_consistency:, adhoc: })adhocthrough thereverse_mergein the n1ql-macro generated method (same pattern asscan_consistency)adhocfromN1ql.configinRelation#build_query_options, covering all relation paths (where,all,first,last,ids,update_all,delete_all)with(adhoc: false)(no dedicatedadhocmethod)Override priority (highest → lowest): per-call kwarg > per-
n1ql-definition option >N1ql.config> default (true).Usage
Test plan
spec/n1ql_spec.rb: defaultadhoc: true, per-call override tofalse,N1ql.configoverridespec/relation_spec.rb: defaultadhoc: true,with(adhoc:)override, config override, chainability/test --fail-fast=falseCI fix
Replaced the brittle
wget+apt install ./libtinfo5_6.3-2ubuntu0.1_amd64.debsteps with a single consolidated apt step that installs from the repository directly and falls back tolibtinfo6on newer Ubuntu runner images (ubuntu-24.04). This eliminates CI failures caused by Ubuntu package pool URLs becoming stale.🤖 Generated with Claude Code