aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-01-16 20:37:02 +0000
committerChristopher Baines <mail@cbaines.net>2020-01-16 20:37:02 +0000
commitbd52629674f7e50b20f5882185a8fe61c30f9191 (patch)
tree547efa8232e63d4691bf85b14275489f0be3eb8b
parent54baf32be6e45a6f328dae0f1d88aac61c3ec1ef (diff)
downloaddata-service-bd52629674f7e50b20f5882185a8fe61c30f9191.tar
data-service-bd52629674f7e50b20f5882185a8fe61c30f9191.tar.gz
Fix insert-build when derivation_output_details_set_id is NULL
I can't figure out how to insert NULL through a param, so just construct a query to insert the values directly.
-rw-r--r--guix-data-service/model/build.scm27
1 files changed, 16 insertions, 11 deletions
diff --git a/guix-data-service/model/build.scm b/guix-data-service/model/build.scm
index 09ebb31..2c2d5df 100644
--- a/guix-data-service/model/build.scm
+++ b/guix-data-service/model/build.scm
@@ -382,19 +382,24 @@ UPDATE builds SET derivation_output_details_set_id = (
(define (insert-build conn build-server-id derivation-file-name)
(match (exec-query
conn
- "
+ (string-append
+ "
INSERT INTO builds
(build_server_id, derivation_file_name, derivation_output_details_set_id)
-VALUES ($1, $2, $3)
-RETURNING (id)"
- (list (number->string build-server-id)
- derivation-file-name
- (or
- (and=> (select-derivations-by-output-details-set-id-by-derivation-file-name
- conn
- derivation-file-name)
- number->string)
- "NULL")))
+VALUES ("
+ (number->string build-server-id)
+ ", "
+ (quote-string derivation-file-name)
+ ", "
+ (or
+ (and=>
+ (select-derivations-by-output-details-set-id-by-derivation-file-name
+ conn
+ derivation-file-name)
+ number->string)
+ "NULL")
+ ")
+RETURNING (id)"))
(((id))
(string->number id))))