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 ()
This commit is contained in:
Christopher Baines 2020-10-08 17:36:21 +01:00
parent 062397e82b
commit f1eb2d3bd2

View file

@ -115,19 +115,26 @@
lst)) lst))
(define (table-schema conn table-name) (define (table-schema conn table-name)
(map (let ((results
(match-lambda (exec-query
((column_name data_type is_nullable) conn
(list column_name "
data_type
(string=? is_nullable "YES"))))
(exec-query
conn
"
SELECT column_name, data_type, is_nullable SELECT column_name, data_type, is_nullable
FROM information_schema.columns FROM information_schema.columns
WHERE table_name = $1" 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 (define* (insert-missing-data-and-return-all-ids
conn conn