1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 16:51:06 -07:00

Allow inserting and selecting binary blobs from sqlite

* doc/lispref/text.texi (Database): Document how to insert binary
data.
* src/sqlite.c (bind_values): Bind BLOB columns correctly (bug#54591).
This commit is contained in:
Lars Ingebrigtsen 2022-04-28 14:58:20 +02:00
parent 613aa18945
commit 5d032f2904
3 changed files with 83 additions and 9 deletions

View file

@ -216,4 +216,29 @@
db "/usr/lib/x86_64-linux-gnu/libsqlite3_mod_csvtable.so")
'(nil t)))))
(ert-deftest sqlite-blob ()
(skip-unless (sqlite-available-p))
(let (db)
(progn
(setq db (sqlite-open))
(sqlite-execute
db "create table if not exists test10 (col1 text, col2 blob, col3 numbre)")
(let ((string (with-temp-buffer
(set-buffer-multibyte nil)
(insert 0 1 2)
(buffer-string))))
(should-not (multibyte-string-p string))
(sqlite-execute
db "insert into test10 values (?, ?, 1)"
(list string
(propertize string
'coding-system 'binary)))
(cl-destructuring-bind
(c1 c2 _)
(car (sqlite-select db "select * from test10 where col3 = 1"))
(should (equal c1 string))
(should (equal c2 string))
(should (multibyte-string-p c1))
(should-not (multibyte-string-p c2)))))))
;;; sqlite-tests.el ends here