SimplyBased 0.1.0 — Couchbase-native ActiveModel ORM
A from-scratch fork of simply_couch's model layer that runs on Couchbase natively: `include SimplyBased::Model` instead of `include SimplyCouch::Model`. - SimplyBased::Store replaces the CouchDB layer: KV documents, N1QL/SQL++ finders + lazily-created GSIs, CAS mapped onto _rev. No design documents or JavaScript map/reduce — the hand-written association views become N1QL (belongs_to/has_many/has_one scalar FK; habtm via ANY ... SATISFIES + array index, or KV multi-get on the storing side). - Redis replacements on the same cluster: Counter (atomic increment/decrement), Cache (ActiveSupport::Cache::Store over KV+TTL, drop-in Rails.cache/ActiveJob), Lock (insert-if-absent + TTL + CAS-checked release). - Runs the simply_couch test suite against live Couchbase: 378/432 applicable examples green (CouchDB-mechanic specs tagged :couchdb_only and excluded). - Remaining: ancestry (tree) + embedded_in reverse-lookups (recursive/embedded N1QL) and a few pagination/lifecycle edges. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
commit
86299b8827
84 files changed
+9904
No files matched your search
@@ -0,0 +1,45 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Equality and hashing" do
|
||||
describe "unsaved records" do
|
||||
it "two distinct new records are not equal" do
|
||||
a = User.new(name: 'a')
|
||||
b = User.new(name: 'a')
|
||||
(a == b).should be false
|
||||
a.eql?(b).should be false
|
||||
end
|
||||
|
||||
it "a new record equals itself" do
|
||||
a = User.new(name: 'a')
|
||||
(a == a).should be true
|
||||
end
|
||||
|
||||
it "new records are distinct inside a Set / uniq / include?" do
|
||||
a = User.new(name: 'a')
|
||||
b = User.new(name: 'b')
|
||||
[a, b].uniq.size.should eq(2)
|
||||
Set.new([a, b]).size.should eq(2)
|
||||
[a].include?(b).should be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "persisted records" do
|
||||
it "two instances with the same _id and _rev are equal" do
|
||||
a = User.new(name: 'a')
|
||||
b = User.new(name: 'b')
|
||||
a._id = b._id = 'same-id'
|
||||
a._rev = b._rev = '1-abc'
|
||||
(a == b).should be true
|
||||
a.hash.should eq(b.hash)
|
||||
end
|
||||
|
||||
it "same _id but different _rev are not equal" do
|
||||
a = User.new
|
||||
b = User.new
|
||||
a._id = b._id = 'same-id'
|
||||
a._rev = '1-abc'
|
||||
b._rev = '2-def'
|
||||
(a == b).should be false
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user