You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parameterize N1QL queries with positional parameters
Replace string-interpolated values with positional parameter placeholders
($1, $2, ...) across n1ql, relation, has_many, and query_helper modules.
This enables Couchbase prepared-statement caching by making query strings
stable regardless of parameter values.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: spec/n1ql_spec.rb
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -172,19 +172,28 @@ class N1QLTest < CouchbaseOrm::Base
172
172
it"should log the default scan_consistency when n1ql query is executed"do
173
173
allow(CouchbaseOrm.logger).toreceive(:debug)
174
174
N1QLTest.by_rating_reverse()
175
-
expect(CouchbaseOrm.logger).tohave_received(:debug).at_least(:once).with("N1QL query: select raw meta().id from `#{CouchbaseOrm::Connection.bucket.name}` where type=\"n1_ql_test\" order by name DESC return 0 rows with scan_consistency : #{described_class::DEFAULT_SCAN_CONSISTENCY}")
msg == "N1QL query: select raw meta().id from `#{CouchbaseOrm::Connection.bucket.name}` where type=$1 order by name DESC params: [\"n1_ql_test\"] return 0 rows with scan_consistency: #{described_class::DEFAULT_SCAN_CONSISTENCY}"
178
+
end
176
179
end
177
180
178
181
it"should log the set scan_consistency when n1ql query is executed with a specific scan_consistency"do
expect(CouchbaseOrm.logger).tohave_received(:debug).at_least(:once).with("N1QL query: select raw meta().id from `#{CouchbaseOrm::Connection.bucket.name}` where type=\"n1_ql_test\" order by name DESC return 0 rows with scan_consistency : not_bounded")
msg == "N1QL query: select raw meta().id from `#{CouchbaseOrm::Connection.bucket.name}` where type=$1 order by name DESC params: [\"n1_ql_test\"] return 0 rows with scan_consistency: not_bounded"
189
+
end
184
190
185
191
CouchbaseOrm::N1ql.config(default_n1ql_config)
186
192
N1QLTest.by_rating_reverse()
187
-
expect(CouchbaseOrm.logger).tohave_received(:debug).at_least(:once).with("N1QL query: select raw meta().id from `#{CouchbaseOrm::Connection.bucket.name}` where type=\"n1_ql_test\" order by name DESC return 0 rows with scan_consistency : #{described_class::DEFAULT_SCAN_CONSISTENCY}")
msg == "N1QL query: select raw meta().id from `#{CouchbaseOrm::Connection.bucket.name}` where type=$1 order by name DESC params: [\"n1_ql_test\"] return 0 rows with scan_consistency: #{described_class::DEFAULT_SCAN_CONSISTENCY}"
0 commit comments