[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/09: Add checks to guard against null data
From: |
Christopher Baines |
Subject: |
02/09: Add checks to guard against null data |
Date: |
Sun, 7 Jun 2020 16:27:58 -0400 (EDT) |
cbaines pushed a commit to branch master
in repository data-service.
commit b8abe38352ff0513dee2bae87d3c17eba3c84339
Author: Danjela Lura <danielaluraa@gmail.com>
AuthorDate: Thu May 28 22:27:48 2020 +0200
Add checks to guard against null data
Signed-off-by: Christopher Baines <mail@cbaines.net>
---
guix-data-service/model/lint-warning.scm | 30 ++++++++++++++++--------------
guix-data-service/model/utils.scm | 22 +++++++++++++---------
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/guix-data-service/model/lint-warning.scm
b/guix-data-service/model/lint-warning.scm
index f22681b..6c83773 100644
--- a/guix-data-service/model/lint-warning.scm
+++ b/guix-data-service/model/lint-warning.scm
@@ -36,20 +36,22 @@
(define (insert-guix-revision-lint-warnings conn
guix-revision-id
lint-warning-ids)
- (exec-query
- conn
- (string-append
- "INSERT INTO guix_revision_lint_warnings (lint_warning_id,
guix_revision_id) "
- "VALUES "
- (string-join
- (map (lambda (lint-warning-id)
- (simple-format
- #f
- "(~A, ~A)"
- lint-warning-id
- guix-revision-id))
- lint-warning-ids)
- ", "))))
+ (if (null? lint-warning-ids)
+ '()
+ (exec-query
+ conn
+ (string-append
+ "INSERT INTO guix_revision_lint_warnings (lint_warning_id,
guix_revision_id) "
+ "VALUES "
+ (string-join
+ (map (lambda (lint-warning-id)
+ (simple-format
+ #f
+ "(~A, ~A)"
+ lint-warning-id
+ guix-revision-id))
+ lint-warning-ids)
+ ", ")))))
(define* (lint-warnings-for-guix-revision conn commit-hash
#:key
diff --git a/guix-data-service/model/utils.scm
b/guix-data-service/model/utils.scm
index 5676c23..79aa7da 100644
--- a/guix-data-service/model/utils.scm
+++ b/guix-data-service/model/utils.scm
@@ -317,10 +317,12 @@ WHERE table_name = $1"
"ANALYZE " temp-table-name))
;; Populate the temporary table
- (with-time-logging (string-append "populating "
temp-table-name)
- (exec-query conn
- (insert-sql data
- #:table-name temp-table-name)))
+ (if (null? data)
+ '()
+ (with-time-logging (string-append "populating "
temp-table-name)
+ (exec-query conn
+ (insert-sql data
+ #:table-name temp-table-name))))
;; Use the temporary table to find the existing values
(let ((result
(with-time-logging
@@ -336,11 +338,13 @@ WHERE table_name = $1"
result))
;; If not using a temporary table, just do a single SELECT query
- (exec-query->vhash conn
- select-query
- cdr
- (lambda (result)
- (string->number (first result))))))
+ (if (null? data)
+ '()
+ (exec-query->vhash conn
+ select-query
+ cdr
+ (lambda (result)
+ (string->number (first result)))))))
(missing-entries
(filter (lambda (field-values)
(not (vhash-assoc
- branch master updated (ae6541a -> 480d718), Christopher Baines, 2020/06/07
- 01/09: Get the translated lint checker descriptions into the database, Christopher Baines, 2020/06/07
- 02/09: Add checks to guard against null data,
Christopher Baines <=
- 05/09: Make the form-horizontal-control procedure aware of hidden inputs, Christopher Baines, 2020/06/07
- 04/09: Make the query that provides locale options look nicer, Christopher Baines, 2020/06/07
- 07/09: Fall back to en_US.utf8 for the lint warnings page for a revision, Christopher Baines, 2020/06/07
- 09/09: Fix lint checker tests, Christopher Baines, 2020/06/07
- 03/09: Use lint checker related translations on some pages, Christopher Baines, 2020/06/07
- 06/09: Provide the comparison page with translated lint warnings, Christopher Baines, 2020/06/07
- 08/09: Fall back to en_US.utf8 in the package page, Christopher Baines, 2020/06/07