Skip to content
Snippets Groups Projects
Unverified Commit b1dd6691 authored by Mathieu Lirzin's avatar Mathieu Lirzin
Browse files

database: sqlite-exec: Return every rows.

Export it.  Add a test.
parent 18e42be3
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@
db-delete-evaluation
db-add-build-log
read-sql-file
sqlite-exec
;; Parameters.
%package-database
;; Macros.
......@@ -39,9 +40,14 @@
MSG to database DB. MSG can contain '~A' and '~S' escape characters which
will be replaced by ARGS."
(let* ((sql (apply simple-format #f msg args))
(stmt (sqlite-prepare db sql)))
(sqlite-step stmt)
(sqlite-finalize stmt)))
(stmt (sqlite-prepare db sql))
(res (let loop ((res '()))
(let ((row (sqlite-step stmt)))
(if (not row)
(reverse! res)
(loop (cons row res)))))))
(sqlite-finalize stmt)
res))
(define %package-database
;; Define to the database file name of this package.
......
......@@ -42,6 +42,16 @@
(test-assert "db-init"
(%db (db-init)))
(test-assert "sqlite-exec"
(begin
(sqlite-exec (%db) "\
INSERT INTO build (job_spec, drv) VALUES ('job1', 'drv1');")
(sqlite-exec (%db) "\
INSERT INTO build (job_spec, drv) VALUES ('job2', 'drv2');")
(sqlite-exec (%db) "\
INSERT INTO build (job_spec, drv) VALUES ('job3', 'drv3');")
(sqlite-exec (%db) "SELECT * FROM build;")))
(test-assert "db-add-evaluation"
(%id (db-add-evaluation (%db) (make-dummy-job))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment