aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/model
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-10-08 17:36:21 +0100
committerChristopher Baines <mail@cbaines.net>2020-10-08 17:36:21 +0100
commitf1eb2d3bd25e09b781a181c5bf17a2f36134fc25 (patch)
treec7ae37c0761fbb5978e895156963996ac99bbd6b /guix-data-service/model
parent062397e82b30f492fb478456098ce6d9bb3e7111 (diff)
downloaddata-service-f1eb2d3bd25e09b781a181c5bf17a2f36134fc25.tar
data-service-f1eb2d3bd25e09b781a181c5bf17a2f36134fc25.tar.gz
Change table-schema to detect when there are no results
This might give more insight to the [1] errors occuring for some builds. 1: error: couldn't find data for locale in ()
Diffstat (limited to 'guix-data-service/model')
-rw-r--r--guix-data-service/model/utils.scm27
1 files changed, 17 insertions, 10 deletions
diff --git a/guix-data-service/model/utils.scm b/guix-data-service/model/utils.scm
index e6c4a2b..13947bd 100644
--- a/guix-data-service/model/utils.scm
+++ b/guix-data-service/model/utils.scm
@@ -115,19 +115,26 @@
lst))
(define (table-schema conn table-name)
- (map
- (match-lambda
- ((column_name data_type is_nullable)
- (list column_name
- data_type
- (string=? is_nullable "YES"))))
- (exec-query
- conn
- "
+ (let ((results
+ (exec-query
+ conn
+ "
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = $1"
- (list table-name))))
+ (list table-name))))
+ (if (null? results)
+ (error
+ (simple-format #f "missing schema for ~A: ~A"
+ table-name
+ results))
+ (map
+ (match-lambda
+ ((column_name data_type is_nullable)
+ (list column_name
+ data_type
+ (string=? is_nullable "YES"))))
+ results))))
(define* (insert-missing-data-and-return-all-ids
conn