emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/triples cca16121d9 13/19: Fix bugs in `triples-remove-t


From: ELPA Syncer
Subject: [elpa] externals/triples cca16121d9 13/19: Fix bugs in `triples-remove-type'.
Date: Sat, 5 Nov 2022 11:58:17 -0400 (EDT)

branch: externals/triples
commit cca16121d967fd8741a26be64bc43de8751365a5
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: Andrew Hyatt <ahyatt@gmail.com>

    Fix bugs in `triples-remove-type'.
    
    Previously, it removed all type markers, and didn't remove the actual type 
data.
    Fix tests so that it caught the previous issue.
---
 triples-test.el | 14 +++++++++++---
 triples.el      |  4 ++--
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/triples-test.el b/triples-test.el
index d94c1e54ec..9277d4a3fa 100644
--- a/triples-test.el
+++ b/triples-test.el
@@ -93,6 +93,10 @@ easily debug into it.")
     (should-error (triples-verify-schema-compliant db '(("foo" named/name 
"bar" (:index 0)))))
     (should (triples-verify-schema-compliant db '(("foo" named/alternate-names 
"bar" (:index 0)))))))
 
+(defun triples-test-list-sort (list)
+  "Sort LIST in a standard way, for comparison."
+  (sort list (lambda (a b) (string< (format "%s" a) (format "%s" b)))))
+
 (defun triples-test-plist-sort (plist)
   "Sort PLIST in a standard way, for comparison."
   (kvalist->plist
@@ -104,15 +108,19 @@ easily debug into it.")
    (triples-add-schema db 'named
                        '(name :base/unique t)
                        'alias)
+   (triples-add-schema db 'callable
+                       '(phone-number :base/unique t))
    (triples-set-type db "foo" 'named :name "Name" :alias '("alias1" "alias2"))
+   (triples-set-type db "foo" 'callable :phone-number "867-5309")
    (should (equal (triples-test-plist-sort '(:name "Name" :alias ("alias1" 
"alias2")))
                   (triples-test-plist-sort (triples-get-type db "foo" 
'named))))
-   (should (equal (triples-get-types db "foo") '(named)))
+   (should (equal (triples-test-list-sort (triples-get-types db "foo"))
+                  (triples-test-list-sort '(callable named))))
    (should-not (triples-get-type db "bar" 'named))
    (should-not (triples-get-types db "bar"))
-   (should (equal '(named) (triples-get-types db "foo")))
    (triples-remove-type db "foo" 'named)
-   (should-not (triples-get-types db "foo"))))
+   (should-not (triples-get-type db "foo" 'named))
+   (should (triples-get-type db "foo" 'callable))))
 
 (ert-deftest triples-crud-all ()
   (triples-test-with-temp-db
diff --git a/triples.el b/triples.el
index 1e52471490..9189c9f805 100644
--- a/triples.el
+++ b/triples.el
@@ -238,9 +238,9 @@ PROPERTIES is a plist of properties, without TYPE prefixes."
   "Remove TYPE for SUBJECT in DB, and all associated data."
   (emacsql-with-transaction db
     (emacsql db [:delete :from triples :where (= subject $s1)
-                 :and (= predicate 'base/type)] subject)
+                 :and (= predicate 'base/type) :and (= object $s2)] subject 
type)
     (emacsql db [:delete :from triples :where (= subject $s1)
-                 :and (like $r2)] subject (format "%s/%%" type))))
+                 :and (like predicate $r2)] subject (format "%s/%%" type))))
 
 (defun triples-get-types (db subject)
   "From DB, get all types for SUBJECT."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]