diff options
| author | Lars Ingebrigtsen | 2022-04-28 14:58:20 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-04-28 14:58:53 +0200 |
| commit | 5d032f2904d4604110e24eb3ae0daf8f7701d72f (patch) | |
| tree | 13a686be0f9936e85d29318b8520606d4fccb92c /test/src/sqlite-tests.el | |
| parent | 613aa1894500f4c707078e71b497662e91f3f6f3 (diff) | |
| download | emacs-5d032f2904d4604110e24eb3ae0daf8f7701d72f.tar.gz emacs-5d032f2904d4604110e24eb3ae0daf8f7701d72f.zip | |
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).
Diffstat (limited to 'test/src/sqlite-tests.el')
| -rw-r--r-- | test/src/sqlite-tests.el | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/src/sqlite-tests.el b/test/src/sqlite-tests.el index 6e44300f3ad..5af43923012 100644 --- a/test/src/sqlite-tests.el +++ b/test/src/sqlite-tests.el | |||
| @@ -216,4 +216,29 @@ | |||
| 216 | db "/usr/lib/x86_64-linux-gnu/libsqlite3_mod_csvtable.so") | 216 | db "/usr/lib/x86_64-linux-gnu/libsqlite3_mod_csvtable.so") |
| 217 | '(nil t))))) | 217 | '(nil t))))) |
| 218 | 218 | ||
| 219 | (ert-deftest sqlite-blob () | ||
| 220 | (skip-unless (sqlite-available-p)) | ||
| 221 | (let (db) | ||
| 222 | (progn | ||
| 223 | (setq db (sqlite-open)) | ||
| 224 | (sqlite-execute | ||
| 225 | db "create table if not exists test10 (col1 text, col2 blob, col3 numbre)") | ||
| 226 | (let ((string (with-temp-buffer | ||
| 227 | (set-buffer-multibyte nil) | ||
| 228 | (insert 0 1 2) | ||
| 229 | (buffer-string)))) | ||
| 230 | (should-not (multibyte-string-p string)) | ||
| 231 | (sqlite-execute | ||
| 232 | db "insert into test10 values (?, ?, 1)" | ||
| 233 | (list string | ||
| 234 | (propertize string | ||
| 235 | 'coding-system 'binary))) | ||
| 236 | (cl-destructuring-bind | ||
| 237 | (c1 c2 _) | ||
| 238 | (car (sqlite-select db "select * from test10 where col3 = 1")) | ||
| 239 | (should (equal c1 string)) | ||
| 240 | (should (equal c2 string)) | ||
| 241 | (should (multibyte-string-p c1)) | ||
| 242 | (should-not (multibyte-string-p c2))))))) | ||
| 243 | |||
| 219 | ;;; sqlite-tests.el ends here | 244 | ;;; sqlite-tests.el ends here |