From b45b17d906c321f9b207c059861576931ad90c35 Mon Sep 17 00:00:00 2001 From: Pierre Merlin Date: Mon, 23 Feb 2026 18:33:13 +0100 Subject: [PATCH] fix: use @model.bucket instead of CouchbaseOrm::Connection.bucket in delete_all `delete_all` was the only method in `CouchbaseOrm_Relation` still using the global `CouchbaseOrm::Connection.bucket`. All other storage accesses (`to_n1ql`, `update_all`, `execute`, `first`, `last`) correctly use `@model.bucket` or `@model.cluster`. This inconsistency was a historical oversight: `delete_all` was introduced in the first commit of the relation class before `@model.bucket` existed, and was never updated when the abstraction was added in later commits. This fix makes `delete_all` consistent with the rest of the class and enables per-model dynamic connection routing (e.g. Couchbase Capella). --- lib/couchbase-orm/relation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/couchbase-orm/relation.rb b/lib/couchbase-orm/relation.rb index 006b831..fc49511 100644 --- a/lib/couchbase-orm/relation.rb +++ b/lib/couchbase-orm/relation.rb @@ -113,7 +113,7 @@ def [](*args) def delete_all CouchbaseOrm::logger.debug{ "Delete all: #{self}" } ids = query.to_a - CouchbaseOrm::Connection.bucket.default_collection.remove_multi(ids) unless ids.empty? + @model.bucket.default_collection.remove_multi(ids) unless ids.empty? end def where(string_cond=nil, **conds)