From 64a4058ccece46c89a39c639c1ab509810c2a403 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 2 Jan 2021 10:06:27 +0000 Subject: Start to add compatibility with squee returning #f for null values While maintaining compatibility for older versions of squee. --- guix-data-service/model/derivation.scm | 46 ++++++++++++++++-------------- guix-data-service/model/git-branch.scm | 6 ++-- guix-data-service/model/git-repository.scm | 9 ++++-- 3 files changed, 34 insertions(+), 27 deletions(-) (limited to 'guix-data-service/model') diff --git a/guix-data-service/model/derivation.scm b/guix-data-service/model/derivation.scm index 8a299be..22986f8 100644 --- a/guix-data-service/model/derivation.scm +++ b/guix-data-service/model/derivation.scm @@ -360,7 +360,8 @@ ORDER BY derivations.file_name (list file_name system target - (if (string-null? builds) + (if (or (and (string? builds) (string-null? builds)) + (eq? #f builds)) #() (json-string->scm builds)))) ((file_name system target) @@ -553,7 +554,8 @@ ORDER BY derivations.file_name (list file_name system target - (if (string-null? builds) + (if (or (and (string? builds) (string-null? builds)) + (eq? #f builds)) #() (json-string->scm builds))))) (exec-query conn @@ -643,26 +645,26 @@ LIMIT $4")) (map (match-lambda ((derivation_file_name latest_build) `((derivation_file_name . ,derivation_file_name) - (latest_build . ,(if - (string-null? latest_build) - 'null - (map (match-lambda - ((key . value) - (cons (string->symbol key) - value))) - (json-string->scm latest_build))))))) - (exec-query conn - query - `(,commit - ,system - ,target - ,(number->string (or limit-results 999999)) ; TODO - ,@(if after-derivation-file-name - (list after-derivation-file-name) - '()) - ,@(if latest-build-status - (list latest-build-status) - '()))))) + (latest_build . ,(if latest_build + (map (match-lambda + ((key . value) + (cons (string->symbol key) + value))) + (json-string->scm latest_build)) + 'null))))) + (exec-query-with-null-handling + conn + query + `(,commit + ,system + ,target + ,(number->string (or limit-results 999999)) ; TODO + ,@(if after-derivation-file-name + (list after-derivation-file-name) + '()) + ,@(if latest-build-status + (list latest-build-status) + '()))))) (define* (select-derivation-outputs-in-revision conn commit-hash diff --git a/guix-data-service/model/git-branch.scm b/guix-data-service/model/git-branch.scm index 19e0ccc..070931d 100644 --- a/guix-data-service/model/git-branch.scm +++ b/guix-data-service/model/git-branch.scm @@ -105,7 +105,8 @@ WHERE git_branches.commit = $1") (list commit datetime (string=? guix_revision_exists "t") - (if (string=? job_events "") + (if (or (and (string? job_events) (string-null? job_events)) + (eq? #f job_events)) '() (vector->list (json-string->scm job_events)))))) (exec-query @@ -161,7 +162,8 @@ ORDER BY name, datetime DESC")) commit datetime (string=? guix_revision_exists "t") - (if (string=? job_events "") + (if (or (and (string? job_events) (string=? job_events "")) + (eq? #f job_events)) '() (vector->list (json-string->scm job_events)))))) (exec-query diff --git a/guix-data-service/model/git-repository.scm b/guix-data-service/model/git-repository.scm index 4eeb99d..9db682e 100644 --- a/guix-data-service/model/git-repository.scm +++ b/guix-data-service/model/git-repository.scm @@ -75,10 +75,12 @@ FROM git_repositories WHERE id = $1" (list (number->string id))) (((included_branches excluded_branches)) (values - (if (string=? included_branches "") + (if (or (eq? #f included_branches) + (string-null? included_branches)) '() (parse-postgresql-array-string included_branches)) - (if (string=? excluded_branches "") + (if (or (eq? excluded_branches #f) + (string-null? excluded_branches)) '() (parse-postgresql-array-string excluded_branches)))))) @@ -144,7 +146,8 @@ ORDER BY 1 DESC NULLS FIRST, 2 DESC LIMIT 10;") ((id job_id job_events commit source) (list id job_id - (if (string=? "" job_events) + (if (or (eq? #f job_events) + (string-null? job_events)) '() (vector->list (json-string->scm job_events))) commit source))) -- cgit v1.2.3