summaryrefslogtreecommitdiff
blob: ffa30dec85cb6cc15fc6dc0df78b67c1f6efd1ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 3cec7dcb201568a09ee9cebf0ea1e43cba9d334a Mon Sep 17 00:00:00 2001
From: Jonas Bernoulli <jonas@bernoul.li>
Date: Tue, 17 Jan 2023 17:33:37 +0100
Subject: [PATCH] Use utf-8 coding-system instead of utf-8-auto
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This fixes an issue that was merely triggered by a change in Emacs
[1].  [2: 127bb98] started binding `coding-system-for-write' and
`coding-system-for-read' to `utf-8-auto'.  As Eli points out at [3]
`utf-8-auto' was probably a mistake and `utf-8' should have been
used instead.

1: https://github.com/emacsmirror/emacs/commit/cfd2b3504ab5de6eb5

2: 2014-02-02 127bb98df20d84117d34822f50ea584af81b19c3
   Set coding system to utf-8-auto for sqlite.

3: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60872#11.

   > Setting coding-system-for-write to utf-8-auto makes no sense;
   > that coding-system's _only_ raison d'être is for using in
   > coding-system-for-read, i.e. when decoding stuff that may or
   > may not start with a BOM.

Since EmacSQL is not a general-purpose database but instead stores
data encoded by Emacs for later retrieval by Emacs only, we do not
have to with the unlikely appearance of a BOM, so we can use `utf-8'
instead of `utf-8-auto' for writes *and* reads.

Re #104, #106, magit/forge#533, magit/forge#535, bug#60872.
---
 emacsql-sqlite.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/emacsql-sqlite.el b/emacsql-sqlite.el
index 1193147..7b8876f 100644
--- a/emacsql-sqlite.el
+++ b/emacsql-sqlite.el
@@ -73,8 +73,9 @@ used.")
   ((connection emacsql-sqlite-connection) &rest _rest)
   (emacsql-sqlite-ensure-binary)
   (let* ((process-connection-type nil)  ; use a pipe
-         (coding-system-for-write 'utf-8-auto)
-         (coding-system-for-read 'utf-8-auto)
+         ;; See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60872#11.
+         (coding-system-for-write 'utf-8)
+         (coding-system-for-read 'utf-8)
          (file (slot-value connection 'file))
          (buffer (generate-new-buffer " *emacsql-sqlite*"))
          (fullfile (if file (expand-file-name file) ":memory:"))