aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service
diff options
context:
space:
mode:
Diffstat (limited to 'guix-data-service')
-rw-r--r--guix-data-service/model/derivation.scm56
1 files changed, 31 insertions, 25 deletions
diff --git a/guix-data-service/model/derivation.scm b/guix-data-service/model/derivation.scm
index 17b1eee..696e2fd 100644
--- a/guix-data-service/model/derivation.scm
+++ b/guix-data-service/model/derivation.scm
@@ -54,6 +54,7 @@
select-derivation-outputs-in-revision
fix-derivation-output-details-hash-encoding
derivation-output-details->derivation-output-details-ids
+ derivation-output-details-ids->derivation-output-details-set-id
select-derivations-by-revision-name-and-version
select-derivation-inputs-by-derivation-id
select-serialized-derivation-by-file-name
@@ -985,26 +986,10 @@ LOCK TABLE ONLY derivation_output_details
(assq-ref details 'recursive)))
derivation-output-details)))
-(define (insert-derivation-outputs conn
- derivation-id
- names-and-derivation-outputs)
- (define (insert-into-derivation-outputs output-names
- derivation-output-details-ids)
- (string-append "INSERT INTO derivation_outputs "
- "(derivation_id, name, derivation_output_details_id) VALUES "
- (string-join
- (map (lambda (output-name derivation-output-details-id)
- (simple-format
- #f "(~A, '~A', ~A)"
- derivation-id
- output-name
- derivation-output-details-id))
- output-names
- derivation-output-details-ids)
- ",")
- ";"))
-
- (define (select-derivation-output-details-sets-id derivation-output-details-ids)
+(define (derivation-output-details-ids->derivation-output-details-set-id
+ conn
+ derivation-output-details-ids)
+ (define (select-derivation-output-details-sets-id)
(match (exec-query
conn
(string-append
@@ -1020,8 +1005,7 @@ WHERE derivation_output_details_ids = ARRAY["
(string->number id))
(_ #f)))
- (define (insert-into-derivation-output-details-sets
- derivation-output-details-ids)
+ (define (insert-into-derivation-output-details-sets)
(match (exec-query
conn
(string-append
@@ -1035,6 +1019,28 @@ RETURNING id"))
(((id))
(string->number id))))
+ (or (select-derivation-output-details-sets-id)
+ (insert-into-derivation-output-details-sets)))
+
+(define (insert-derivation-outputs conn
+ derivation-id
+ names-and-derivation-outputs)
+ (define (insert-into-derivation-outputs output-names
+ derivation-output-details-ids)
+ (string-append "INSERT INTO derivation_outputs "
+ "(derivation_id, name, derivation_output_details_id) VALUES "
+ (string-join
+ (map (lambda (output-name derivation-output-details-id)
+ (simple-format
+ #f "(~A, '~A', ~A)"
+ derivation-id
+ output-name
+ derivation-output-details-id))
+ output-names
+ derivation-output-details-ids)
+ ",")
+ ";"))
+
(define (insert-into-derivations-by-output-details-set
derivation_output_details_set_id)
(exec-query
@@ -1072,9 +1078,9 @@ VALUES ($1, $2)"
derivation-output-details-ids))
(insert-into-derivations-by-output-details-set
- (or
- (select-derivation-output-details-sets-id derivation-output-details-ids)
- (insert-into-derivation-output-details-sets derivation-output-details-ids)))
+ (derivation-output-details-ids->derivation-output-details-set-id
+ conn
+ derivation-output-details-ids))
derivation-output-details-ids))