Tienson Qin преди 12 часа
родител
ревизия
910cd9514f
променени са 3 файла, в които са добавени 21 реда и са изтрити 21 реда
  1. 5 3
      deps/outliner/src/logseq/outliner/core.cljs
  2. 2 3
      src/test/frontend/db/query_dsl_test.cljs
  3. 14 15
      src/test/frontend/modules/outliner/core_test.cljs

+ 5 - 3
deps/outliner/src/logseq/outliner/core.cljs

@@ -10,6 +10,7 @@
             [logseq.common.util.page-ref :as page-ref]
             [logseq.common.uuid :as common-uuid]
             [logseq.db :as ldb]
+            [logseq.db.common.entity-plus :as entity-plus]
             [logseq.db.common.order :as db-order]
             [logseq.db.frontend.class :as db-class]
             [logseq.db.frontend.schema :as db-schema]
@@ -298,7 +299,8 @@
                               :or {retract-attributes? true}}]
     (assert (ds/outliner-txs-state? *txs-state)
             "db should be satisfied outliner-tx-state?")
-    (let [data (if (de/entity? this)
+    (let [db-graph? (entity-plus/db-based-graph? db)
+          data (if (de/entity? this)
                  (assoc (.-kv ^js this) :db/id (:db/id this))
                  this)
           data' (->> (dissoc data :block/properties)
@@ -309,7 +311,7 @@
                   (dissoc :block/children :block/meta :block/unordered
                           :block.temp/ast-title :block.temp/ast-body :block/level :block.temp/load-status
                           :block.temp/has-children?)
-                  (fix-tag-ids db {:db-graph? true}))
+                  (fix-tag-ids db {:db-graph? db-graph?}))
                (not collapse-or-expand?)
                block-with-updated-at)
           db-id (:db/id this)
@@ -366,7 +368,7 @@
           (update-page-when-save-block *txs-state block-entity m))
         ;; Remove orphaned refs from block
         (when (and (:block/title m) (not= (:block/title m) (:block/title block-entity)))
-          (remove-orphaned-refs-when-save db *txs-state block-entity m {:db-graph? true})))
+          (remove-orphaned-refs-when-save db *txs-state block-entity m {:db-graph? db-graph?})))
 
       ;; handle others txs
       (let [other-tx (:db/other-tx m)]

+ 2 - 3
src/test/frontend/db/query_dsl_test.cljs

@@ -639,9 +639,8 @@ prop-d:: [[nada]]"}])
                 (dsl-query "(or [[tag2]] [[page not exists]])")))
         "OR query with nonexistent page should return meaningful results")
 
-    (comment
-      ;; FIXME:
-      (is (= (if js/process.env.DB_GRAPH #{"b1" "bar" "b3"} #{"b1" "foo:: bar" "b3"})
+    (when js/process.env.DB_GRAPH
+      (is (= #{"b1" "bar" "b3"}
              (->> (dsl-query "(not [[page 2]])")
                 ;; Only filter to page1 to get meaningful results
                   (filter #(= "page1" (get-in % [:block/page :block/name])))

+ 14 - 15
src/test/frontend/modules/outliner/core_test.cljs

@@ -529,21 +529,20 @@ tags:: tag1, tag2
       (is (nil? (:block/tags updated-page))
           "Page's tags are deleted")))
 
-  (comment
-    ;; FIXME:
-    (testing "save deletes orphaned pages when a block's refs change"
-      (let [conn (db/get-db test-db false)
-            pages (set (map first (d/q '[:find ?bn :where [?b :block/name ?bn]] @conn)))
-            _ (assert (set/subset? #{"blarg" "bar"} pages) "Pages from block exist")
-            block-with-refs (ffirst (d/q '[:find (pull ?b [* {:block/refs [*]}])
-                                           :where [?b :block/title "block #blarg #bar"]]
-                                         @conn))
-            _ (save-block! (-> block-with-refs
-                               (assoc :block/title "block"
-                                      :block/refs [])))
-            updated-pages (set (map first (d/q '[:find ?bn :where [?b :block/name ?bn]] @conn)))]
-        (is (not (contains? updated-pages "blarg"))
-            "Deleted, orphaned page no longer exists")))))
+  ;; FIXME:
+  (testing "save deletes orphaned pages when a block's refs change"
+    (let [conn (db/get-db test-db false)
+          pages (set (map first (d/q '[:find ?bn :where [?b :block/name ?bn]] @conn)))
+          _ (assert (set/subset? #{"blarg" "bar"} pages) "Pages from block exist")
+          block-with-refs (ffirst (d/q '[:find (pull ?b [* {:block/refs [*]}])
+                                         :where [?b :block/title "block #blarg #bar"]]
+                                       @conn))
+          _ (save-block! (-> block-with-refs
+                             (assoc :block/title "block"
+                                    :block/refs [])))
+          updated-pages (set (map first (d/q '[:find ?bn :where [?b :block/name ?bn]] @conn)))]
+      (is (not (contains? updated-pages "blarg"))
+          "Deleted, orphaned page no longer exists"))))
 
 ;;; Fuzzy tests