diff options
author | Christopher Baines <mail@cbaines.net> | 2021-01-17 20:27:58 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-01-17 20:27:58 +0000 |
commit | 2123064a21236e9a91716effef4fc522172a95fd (patch) | |
tree | 5e8b5c2e204844de4d260b8102a37d9266c9380e /guix-build-coordinator/datastore | |
parent | 7572f18c00d628d7ac45d7ab0096af03780ae540 (diff) | |
download | build-coordinator-2123064a21236e9a91716effef4fc522172a95fd.tar build-coordinator-2123064a21236e9a91716effef4fc522172a95fd.tar.gz |
Stop treating collections of tags as alists
This translates poorly to JSON, as you can't have multiple values for one name
in a JSON object. Is also is risky in terms of assoc-ref being used, and not
considering more than one key. Using a vector of pairs should help in both
situations.
Diffstat (limited to 'guix-build-coordinator/datastore')
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index ecd6097..6af0b46 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -399,14 +399,15 @@ WHERE agent_tags.agent_id = :agent_id" #:agent_id agent-id) (let ((result - (sqlite-fold - (lambda (row result) - (match row - (#(key value) - `((,key . ,value) - ,@result)))) - '() - statement))) + (list->vector + (sqlite-fold + (lambda (row result) + (match row + (#(key value) + `((,key . ,value) + ,@result)))) + '() + statement)))) (sqlite-reset statement) result))))) @@ -760,7 +761,9 @@ INSERT INTO build_tags (build_id, tag_id) VALUES (:build_id, :tag_id)" #:tag_id (tag->id key value)) (sqlite-step build-tags-statement) (sqlite-reset build-tags-statement))) - tags)))) + (if (vector? tags) + (vector->list tags) + tags))))) #t) (define-method (datastore-cancel-build @@ -1457,14 +1460,15 @@ WHERE build_tags.build_id = :build_id" #:build_id build-id) (let ((result - (sqlite-fold - (lambda (row result) - (match row - (#(key value) - `((,key . ,value) - ,@result)))) - '() - statement))) + (list->vector + (sqlite-fold + (lambda (row result) + (match row + (#(key value) + `((,key . ,value) + ,@result)))) + '() + statement)))) (sqlite-reset statement) result))))) |