branch: externals/triples
commit 992d81f24a9267e8386a08815f6251b6b99061c2
Author: Andrew Hyatt <[email protected]>
Commit: Andrew Hyatt <[email protected]>

    Fix `triples-subjects-with-predicate-object'.
    
    Previously, we were returning the whole triples, and not the subject, as the
    documentation and name of the subject specified.
---
 triples-test.el | 6 ++++++
 triples.el      | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/triples-test.el b/triples-test.el
index d0f2b9a2da..44d92ab2da 100644
--- a/triples-test.el
+++ b/triples-test.el
@@ -162,6 +162,12 @@ easily debug into it.")
                      (triples-db-select-predicate-object-fragment db 'pred/foo 
"whole"))
              '((sub1 pred/foo "a whole phrase"))))))
 
+(triples-deftest triples-test-subjects-with-predicate-object ()
+  (triples-test-with-temp-db
+    (triples-db-insert db 'sub1 'pred/foo "bar")
+    (should (equal (triples-subjects-with-predicate-object db 'pred/foo "bar")
+                   '(sub1)))))
+
 ;; After this we don't bother testing both with emacsql and the builtin sqlite,
 ;; since if the functions tested above work, it should also work for both.
 
diff --git a/triples.el b/triples.el
index 301ba15bde..5d3d3551f5 100644
--- a/triples.el
+++ b/triples.el
@@ -534,11 +534,11 @@ TYPE-VALS-CONS is a list of conses, combining a type and 
a plist of values."
 
 (defun triples-subjects-with-predicate-object (db cpred obj)
   "Return all subjects in DB with CPRED equal to OBJ."
-  (triples-db-select db nil cpred obj))
+  (mapcar #'car (triples-db-select db nil cpred obj)))
 
 (defun triples-subjects-of-type (db type)
   "Return a list of all subjects with a particular TYPE in DB."
-  (mapcar #'car (triples-subjects-with-predicate-object db 'base/type type)))
+  (triples-subjects-with-predicate-object db 'base/type type))
 
 (defun triples-combined-to-type-and-prop (combined)
   "Return cons of type and prop that form the COMBINED normal representation.

Reply via email to