File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 4646 nil )))
4747 (.count history))
4848
49+ (defn- write-value! [^WriteCursor cursor new-value]
50+ (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" )))
56+ (.write cursor (common/-slot new-value)))
57+ (conversion/v->slot! cursor new-value)))
58+
4959(defn xitdb-reset!
5060 " Sets the value of the database to `new-value`.
5161 Returns new history index."
5262 [^WriteArrayList history new-value]
5363 (append-context! history nil (fn [^WriteCursor cursor]
54- (if (satisfies? common/ISlot new-value)
55- (.write cursor (common/-slot new-value))
56- (conversion/v->slot! cursor new-value)))))
64+ (write-value! cursor new-value))))
5765
5866(defn v->slot!
5967 " Converts a value to a slot which can be written to a cursor.
8189 (let [cursor (conversion/keypath-cursor cursor base-keypath)
8290 obj (xtypes/read-from-cursor cursor true )]
8391 (let [retval (apply f (into [obj] args))]
84- (. write cursor ( v->slot ! cursor retval) )))))))
92+ (write-value ! cursor retval)))))))
8593
8694(defn xitdb-swap-with-lock!
8795 " Performs the 'swap!' operation while locking `db.lock`.
You can’t perform that action at this time.
0 commit comments