2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/data-service.git synced 2023-12-14 03:23:03 +01:00

Avoid an error when there are no references to insert

This commit is contained in:
Christopher Baines 2020-02-15 18:23:04 +00:00
parent 36254f98e3
commit a6e19a4102

View file

@ -60,27 +60,28 @@
'(store_path hash_algorithm hash size system deriver)
data)))
(exec-query
conn
(string-append
"
(let ((reference-data
(concatenate
(map (lambda (nar-id narinfo)
(map (lambda (reference)
(simple-format
#f
"(~A, ~A)"
nar-id
(quote-string reference)))
(narinfo-references narinfo)))
nar-ids
narinfos))))
(unless (null? reference-data)
(exec-query
conn
(string-append
"
INSERT INTO nar_references (nar_id, reference)
VALUES "
(string-join
(concatenate
(map (lambda (nar-id narinfo)
(map (lambda (reference)
(simple-format
#f
"(~A, ~A)"
nar-id
(quote-string reference)))
(narinfo-references narinfo)))
nar-ids
narinfos))
", ")
"
ON CONFLICT DO NOTHING"))
(string-join reference-data ", ")
"
ON CONFLICT DO NOTHING"))))
(exec-query
conn