[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/triples 905513b40a 1/2: Fix `triples-subjects-with-pred
From: |
ELPA Syncer |
Subject: |
[elpa] externals/triples 905513b40a 1/2: Fix `triples-subjects-with-predicate-object'. |
Date: |
Thu, 1 Dec 2022 01:58:31 -0500 (EST) |
branch: externals/triples
commit 905513b40a86e5fcb7463278a5828959e56a0fce
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: Andrew Hyatt <ahyatt@gmail.com>
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 e299dc5b53..d9774f52c8 100644
--- a/triples-test.el
+++ b/triples-test.el
@@ -155,6 +155,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 44b528d63a..237acce654 100644
--- a/triples.el
+++ b/triples.el
@@ -498,11 +498,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.