From d3913a14d55968e505429693a6df6125e3468300 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 4 Sep 2019 19:24:22 +0200 Subject: Start handling ids as numbers, rather than strings squee, returns all data as strings, and expects strings as inputs to queries. So, keeping the ids as strings was easy initially, but it means that you can't tell from the type whether it should be quoted, or not... Therefore, handle ids as strings, converting them to numbers when they're fetched from the database, and back to strings as part of the queries. --- guix-data-service/model/license-set.scm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'guix-data-service/model/license-set.scm') diff --git a/guix-data-service/model/license-set.scm b/guix-data-service/model/license-set.scm index 61ded10..0ff253e 100644 --- a/guix-data-service/model/license-set.scm +++ b/guix-data-service/model/license-set.scm @@ -20,7 +20,7 @@ FROM license_sets") "('{" (string-join (map number->string - (sort (map string->number license-ids) <)) + (sort license-ids <)) ", ") "}')")) license-id-lists) @@ -39,12 +39,15 @@ FROM license_sets") (lambda (results) (if (string=? (second results) "{}") '() - (string-split - (string-drop-right - (string-drop (second results) 1) - 1) - #\,))) - first)) ;; id + (map + string->number + (string-split + (string-drop-right + (string-drop (second results) 1) + 1) + #\,)))) + (lambda (result) + (string->number (first result))))) ;; id (missing-license-sets (delete-duplicates (filter (lambda (license-set-license-ids) @@ -54,7 +57,8 @@ FROM license_sets") (new-license-set-entries (if (null? missing-license-sets) '() - (map first + (map (lambda (result) + (string->number (first result))) (exec-query conn (insert-license-sets missing-license-sets))))) (new-entries-id-lookup-vhash -- cgit v1.2.3