Skip to content

Commit 38a6d01

Browse files
committed
remove different database check
1 parent baaba8d commit 38a6d01

File tree

2 files changed

+1
-41
lines changed

2 files changed

+1
-41
lines changed

src/xitdb/db.clj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@
4848

4949
(defn- write-value! [^WriteCursor cursor new-value]
5050
(if (satisfies? common/ISlot new-value)
51-
(let [db (.db cursor)
52-
coll (common/-unwrap new-value)
53-
coll-db (-> coll .cursor .db)]
54-
(when (not= db coll-db)
55-
(throw (IllegalArgumentException. "Cannot write value from a different database. You must materialize it first.")))
56-
(.write cursor (common/-slot new-value)))
51+
(.write cursor (common/-slot new-value))
5752
(.write cursor (conversion/v->slot! cursor new-value))))
5853

5954
(defn xitdb-reset!

test/xitdb/database_test.clj

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -483,42 +483,7 @@
483483
;; Cross-database reset! tests
484484
;; =============================================================================
485485

486-
(deftest reset-with-islot-value-test
487-
(testing "reset! throws when using ISlot values from a different database"
488-
(with-open [db1 (xdb/xit-db :memory)
489-
db2 (xdb/xit-db :memory)]
490-
;; Set up first database with some data
491-
(reset! db1 {:users [{:name "Alice"} {:name "Bob"}]
492-
:config {:theme "dark"}})
493-
494-
;; Get the value from db1 (which implements ISlot)
495-
(let [val-from-db1 @db1]
496-
;; Attempting to reset db2 with an ISlot from db1 should throw
497-
(is (thrown? IllegalArgumentException (reset! db2 val-from-db1))))))
498-
499-
(testing "reset! works when materializing the value first"
500-
(with-open [db1 (xdb/xit-db :memory)
501-
db2 (xdb/xit-db :memory)]
502-
(reset! db1 {:users [{:name "Alice"} {:name "Bob"}]
503-
:config {:theme "dark"}})
504-
505-
;; Materialize the value before passing to reset!
506-
(reset! db2 (tu/materialize @db1))
507-
508-
;; db2 should now have the same data
509-
(is (= (tu/materialize @db1) (tu/materialize @db2))))))
510-
511486
(deftest reset-with-nested-islot-value-test
512-
(testing "reset! throws when using nested ISlot values from a different database"
513-
(with-open [db1 (xdb/xit-db :memory)
514-
db2 (xdb/xit-db :memory)]
515-
(reset! db1 {:data [[1 2 3] [4 5 6] [7 8 9]]})
516-
517-
;; Get a nested value that implements ISlot
518-
(let [nested-val (get @db1 :data)]
519-
;; Attempting to reset db2 with an ISlot from db1 should throw
520-
(is (thrown? IllegalArgumentException (reset! db2 nested-val))))))
521-
522487
(testing "reset! works with nested values when materializing first"
523488
(with-open [db1 (xdb/xit-db :memory)
524489
db2 (xdb/xit-db :memory)]

0 commit comments

Comments
 (0)