[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/triples 4be631ae95 15/16: Fix inescapification that can
From: |
ELPA Syncer |
Subject: |
[elpa] externals/triples 4be631ae95 15/16: Fix inescapification that can happen in strings |
Date: |
Tue, 21 Feb 2023 20:58:53 -0500 (EST) |
branch: externals/triples
commit 4be631ae9531d8ea729a1de42da79127d04f2fae
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: Andrew Hyatt <ahyatt@gmail.com>
Fix inescapification that can happen in strings
We want to be able to store something and have it be retrieved exactly the
same.
To that end, let's no longer have on control character escapification.
Also,
stop our incorrect string munging in favor of simply reading values in the
majority of situations.
---
triples-test.el | 10 ++++++++++
triples.el | 12 +++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/triples-test.el b/triples-test.el
index 1f1fbbe541..c0a073fd98 100644
--- a/triples-test.el
+++ b/triples-test.el
@@ -296,6 +296,16 @@ easily debug into it.")
(should (equal '(:name ("Name"))
(triples-get-type db "foo" 'named)))))
+(ert-deftest triples-store-and-retrieve ()
+ (triples-test-with-temp-db
+ (triples-add-schema db 'text '(text :base/unique t))
+ (let ((text "Foo\nBar\tBaz \"Quoted\" "))
+ (triples-set-type db "foo" 'text :text text)
+ (let ((retrieved (triples-get-type db "foo" 'text)))
+ (should (equal `(:text ,text) retrieved))
+ (triples-set-type db "foo" 'text retrieved)
+ (should (equal `(:text ,text) (triples-get-type db "foo" 'text)))))))
+
(ert-deftest triples-vector ()
(triples-test-with-temp-db
(triples-add-schema db 'named 'name)
diff --git a/triples.el b/triples.el
index f5092a8834..73d50223b0 100644
--- a/triples.el
+++ b/triples.el
@@ -138,7 +138,9 @@ exist at any time. Older backups are the ones that are
deleted."
This is done to have compatibility with the way emacsql stores
values. Turn a symbol into a string as well, but not a quoted
one, because sqlite cannot handle symbols."
- (let ((print-escape-control-characters t))
+ ;; Do not print control characters escaped - we want to get things out
exactly
+ ;; as we put them in.
+ (let ((print-escape-control-characters nil))
(if val
(format "%S" val)
;; Just to save a bit of space, let's use "()" instead of "null", which
is
@@ -150,13 +152,9 @@ one, because sqlite cannot handle symbols."
This imitates the way emacsql returns items, with strings
becoming either symbols, lists, or strings depending on whether
the string itself is wrapped in quotes."
- (if (and (stringp result)
- (string-prefix-p "\"" result)
- (string-suffix-p "\"" result))
- (string-remove-suffix "\"" (string-remove-prefix "\"" result))
- (if (numberp result)
+ (if (numberp result)
result
- (read result))))
+ (read result)))
(defun triples-db-insert (db subject predicate object &optional properties)
"Insert triple to DB: SUBJECT, PREDICATE, OBJECT with PROPERTIES.
- [elpa] externals/triples 5b3c1f191a 02/16: Create `triples-backup' and some surrounding functionality., (continued)
- [elpa] externals/triples 5b3c1f191a 02/16: Create `triples-backup' and some surrounding functionality., ELPA Syncer, 2023/02/21
- [elpa] externals/triples faf376c55c 04/16: Note new triples-backups module in CHANGELOG.org., ELPA Syncer, 2023/02/21
- [elpa] externals/triples 76aa341e6f 07/16: Add `triples-mode-subject', for renaming a subject., ELPA Syncer, 2023/02/21
- [elpa] externals/triples c09ef2932c 08/16: Merge branch 'main' into develop, ELPA Syncer, 2023/02/21
- [elpa] externals/triples a759cddd94 03/16: Add `triples-backups' module., ELPA Syncer, 2023/02/21
- [elpa] externals/triples e24233b65b 09/16: Fix minor misspelling, ELPA Syncer, 2023/02/21
- [elpa] externals/triples 183bd8156f 12/16: Remove trailing whitespace, ELPA Syncer, 2023/02/21
- [elpa] externals/triples 0620d0f25d 11/16: Fix error in `triples-backup' when called with nil argument, ELPA Syncer, 2023/02/21
- [elpa] externals/triples ac10a3cc04 14/16: Test the ability to store vectors, ELPA Syncer, 2023/02/21
- [elpa] externals/triples 8a48e2b2f4 16/16: Set version to 0.2.5, ELPA Syncer, 2023/02/21
- [elpa] externals/triples 4be631ae95 15/16: Fix inescapification that can happen in strings,
ELPA Syncer <=
- [elpa] externals/triples 91536349e9 13/16: Warn against usage of `triples-delete-subject', ELPA Syncer, 2023/02/21