Start to add compatibility with squee returning #f for null values

While maintaining compatibility for older versions of squee.
This commit is contained in:
Christopher Baines 2021-01-02 10:06:27 +00:00
parent 7df6f92036
commit 64a4058cce
6 changed files with 53 additions and 38 deletions

View File

@ -548,7 +548,8 @@ ORDER BY coalesce(base_packages.name, target_packages.name) ASC, base_packages.v
(define (package-data->package-data-vhashes package-data)
(define (add-data-to-vhash data vhash)
(let ((key (first data)))
(if (string-null? key)
(if (or (eq? #f key)
(string-null? key))
vhash
(vhash-cons key
(drop data 1)
@ -567,7 +568,8 @@ ORDER BY coalesce(base_packages.name, target_packages.name) ASC, base_packages.v
(define (package-derivation-data->package-derivation-data-vhashes package-data)
(define (add-data-to-vhash data vhash)
(let ((key (first data)))
(if (string-null? key)
(if (or (eq? key #f)
(string-null? key))
vhash
(vhash-cons key
(drop data 1)
@ -600,7 +602,8 @@ ORDER BY coalesce(base_packages.name, target_packages.name) ASC, base_packages.v
'()
(map (match-lambda
((base-name base-version _ _ _ _ _ target-name target-version _ _ _ _ _)
(if (string-null? base-name)
(if (or (and (string? base-name) (string-null? base-name))
(eq? base-name #f))
(cons target-name target-version)
(cons base-name base-version))))
package-data))))
@ -733,7 +736,9 @@ ORDER BY coalesce(base_packages.name, target_packages.name) ASC, base_packages.v
`((system . ,system)
(target . ,target)
(derivation-file-name . ,derivation-file-name)
(builds . ,(if (string-null? builds)
(builds . ,(if (or (and (string? builds)
(string-null? builds))
(eq? #f builds))
#()
(json-string->scm builds))))))
,@(derivation-system-and-target-list->alist (cdr lst)))))

View File

@ -191,12 +191,14 @@
(map
(lambda (col-i)
(let ((val (result-get-value result-ptr row-i col-i)))
(if (string-null? val)
(if (eq? 1 (%PQgetisnull
(squee/unwrap-result-ptr result-ptr) row-i col-i))
'()
val)
val)))
(cond
((eq? #f val) '())
((string-null? val)
(if (eq? 1 (%PQgetisnull
(squee/unwrap-result-ptr result-ptr) row-i col-i))
'()
val))
(else val))))
cols-range))
rows-range)))

View File

@ -1587,7 +1587,8 @@ ORDER BY load_new_guix_revision_jobs.id DESC")
((id source git-repository-id created-at succeeded-at
events-json log-exists?)
(list id commit source git-repository-id created-at succeeded-at
(if (string-null? events-json)
(if (or (eq? #f events-json)
(string-null? events-json))
#()
(json-string->scm events-json))
(string=? log-exists? "t"))))

View File

@ -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

View File

@ -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

View File

@ -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)))