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

View file

@ -191,12 +191,14 @@
(map (map
(lambda (col-i) (lambda (col-i)
(let ((val (result-get-value result-ptr row-i col-i))) (let ((val (result-get-value result-ptr row-i col-i)))
(if (string-null? val) (cond
(if (eq? 1 (%PQgetisnull ((eq? #f val) '())
(squee/unwrap-result-ptr result-ptr) row-i col-i)) ((string-null? val)
'() (if (eq? 1 (%PQgetisnull
val) (squee/unwrap-result-ptr result-ptr) row-i col-i))
val))) '()
val))
(else val))))
cols-range)) cols-range))
rows-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 ((id source git-repository-id created-at succeeded-at
events-json log-exists?) events-json log-exists?)
(list id commit source git-repository-id created-at succeeded-at (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)) (json-string->scm events-json))
(string=? log-exists? "t")))) (string=? log-exists? "t"))))

View file

@ -360,7 +360,8 @@ ORDER BY derivations.file_name
(list file_name (list file_name
system system
target target
(if (string-null? builds) (if (or (and (string? builds) (string-null? builds))
(eq? #f builds))
#() #()
(json-string->scm builds)))) (json-string->scm builds))))
((file_name system target) ((file_name system target)
@ -553,7 +554,8 @@ ORDER BY derivations.file_name
(list file_name (list file_name
system system
target target
(if (string-null? builds) (if (or (and (string? builds) (string-null? builds))
(eq? #f builds))
#() #()
(json-string->scm builds))))) (json-string->scm builds)))))
(exec-query conn (exec-query conn
@ -643,26 +645,26 @@ LIMIT $4"))
(map (match-lambda (map (match-lambda
((derivation_file_name latest_build) ((derivation_file_name latest_build)
`((derivation_file_name . ,derivation_file_name) `((derivation_file_name . ,derivation_file_name)
(latest_build . ,(if (latest_build . ,(if latest_build
(string-null? latest_build) (map (match-lambda
'null ((key . value)
(map (match-lambda (cons (string->symbol key)
((key . value) value)))
(cons (string->symbol key) (json-string->scm latest_build))
value))) 'null)))))
(json-string->scm latest_build))))))) (exec-query-with-null-handling
(exec-query conn conn
query query
`(,commit `(,commit
,system ,system
,target ,target
,(number->string (or limit-results 999999)) ; TODO ,(number->string (or limit-results 999999)) ; TODO
,@(if after-derivation-file-name ,@(if after-derivation-file-name
(list after-derivation-file-name) (list after-derivation-file-name)
'()) '())
,@(if latest-build-status ,@(if latest-build-status
(list latest-build-status) (list latest-build-status)
'()))))) '())))))
(define* (select-derivation-outputs-in-revision conn (define* (select-derivation-outputs-in-revision conn
commit-hash commit-hash

View file

@ -105,7 +105,8 @@ WHERE git_branches.commit = $1")
(list commit (list commit
datetime datetime
(string=? guix_revision_exists "t") (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)))))) (vector->list (json-string->scm job_events))))))
(exec-query (exec-query
@ -161,7 +162,8 @@ ORDER BY name, datetime DESC"))
commit commit
datetime datetime
(string=? guix_revision_exists "t") (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)))))) (vector->list (json-string->scm job_events))))))
(exec-query (exec-query

View file

@ -75,10 +75,12 @@ FROM git_repositories WHERE id = $1"
(list (number->string id))) (list (number->string id)))
(((included_branches excluded_branches)) (((included_branches excluded_branches))
(values (values
(if (string=? included_branches "") (if (or (eq? #f included_branches)
(string-null? included_branches))
'() '()
(parse-postgresql-array-string 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)))))) (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) ((id job_id job_events commit source)
(list id (list id
job_id job_id
(if (string=? "" job_events) (if (or (eq? #f job_events)
(string-null? job_events))
'() '()
(vector->list (json-string->scm job_events))) (vector->list (json-string->scm job_events)))
commit source))) commit source)))