Improve some derivation model functions
Return integer values for ids, rather than strings (as this type is more appropriate). Also, better parse the derivation arguments and environment variables.
This commit is contained in:
parent
4710d4e398
commit
7b3bc5bcfa
2 changed files with 16 additions and 6 deletions
|
|
@ -60,7 +60,7 @@
|
|||
"WHERE builds.derivation_id = $1 "
|
||||
"ORDER BY latest_build_status.status_fetched_at DESC "))
|
||||
|
||||
(exec-query conn query (list derivation-id)))
|
||||
(exec-query conn query (list (number->string derivation-id))))
|
||||
|
||||
(define (select-build-by-build-server-and-id
|
||||
conn build-server-id id)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#:use-module (ice-9 vlist)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (squee)
|
||||
#:use-module (json)
|
||||
#:use-module (guix base32)
|
||||
#:use-module (guix inferior)
|
||||
#:use-module (guix memoization)
|
||||
|
|
@ -202,15 +203,24 @@ ORDER BY derivations.system DESC,
|
|||
(define (select-derivation-by-file-name conn file-name)
|
||||
(define query
|
||||
(string-append
|
||||
"SELECT id, file_name, builder, args, env_vars, system "
|
||||
"SELECT id, file_name, builder, args, to_json(env_vars), system "
|
||||
"FROM derivations "
|
||||
"WHERE file_name = $1"))
|
||||
|
||||
(match (exec-query conn query (list file-name))
|
||||
(()
|
||||
#f)
|
||||
((result)
|
||||
result)))
|
||||
(((id file_name builder args env_vars system))
|
||||
(list (string->number id)
|
||||
file-name
|
||||
builder
|
||||
(parse-postgresql-array-string args)
|
||||
(map (match-lambda
|
||||
(#(key value)
|
||||
`((key . ,key)
|
||||
(value . ,value))))
|
||||
(vector->list (json-string->scm env_vars)))
|
||||
system))))
|
||||
|
||||
(define select-derivation-output-id
|
||||
(mlambda (conn name path)
|
||||
|
|
@ -240,7 +250,7 @@ ORDER BY derivations.system DESC,
|
|||
"derivation_outputs.derivation_output_details_id = derivation_output_details.id "
|
||||
"WHERE derivation_id = $1"))
|
||||
|
||||
(exec-query conn query (list id)))
|
||||
(exec-query conn query (list (number->string id))))
|
||||
|
||||
(define (select-derivation-inputs-by-derivation-id conn id)
|
||||
(define query
|
||||
|
|
@ -258,7 +268,7 @@ INNER JOIN derivations
|
|||
WHERE derivation_inputs.derivation_id = $1
|
||||
ORDER BY derivations.file_name"))
|
||||
|
||||
(exec-query conn query (list id)))
|
||||
(exec-query conn query (list (number->string id))))
|
||||
|
||||
(define (insert-derivation-inputs conn derivation-id derivation-inputs)
|
||||
(define (insert-into-derivation-inputs output-ids)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue