Skip to content

Commit a91a420

Browse files
pimpinclaude
andcommitted
fix: preserve all query options in has_many n1ql query_fn
The query_fn rebuilt a fresh Couchbase::Options::Query copying only scan_consistency, silently dropping every other option the caller set (timeout, adhoc, client_context_id, profile, etc.). Mutate the existing options object via #positional_parameters and pass it through, so all caller-supplied options are retained. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent fe0c506 commit a91a420

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

lib/couchbase-orm/utilities/has_many.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,8 @@ def build_index_n1ql(klass, remote_class, remote_method, through_key, foreign_ke
9797
n1ql remote_method, emit_key: 'id', query_fn: proc { |bucket, values, options|
9898
raise ArgumentError, "values[0] must not be blank" if values[0].blank?
9999
n1ql_query = "SELECT raw #{through_key} FROM `#{bucket.name}` where type = \"#{design_document}\" and #{foreign_key} = $1"
100-
params = [values[0]]
101-
cluster.query(n1ql_query, Couchbase::Options::Query.new(
102-
positional_parameters: params,
103-
scan_consistency: options.instance_variable_get(:@scan_consistency)
104-
))
100+
options.positional_parameters([values[0]])
101+
cluster.query(n1ql_query, options)
105102
}
106103
end
107104
else

0 commit comments

Comments
 (0)