aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-11-09 20:27:14 +0000
committerChristopher Baines <mail@cbaines.net>2019-11-09 20:27:14 +0000
commit4710d4e3983b48d41f56a9ac17b2ecf31af2a6dd (patch)
tree127f835019eb5c3dbcf05e071ac907bcd3b11dff
parent04bb2d52bc28c02648974c3ee92dbbacb00a1e52 (diff)
downloaddata-service-4710d4e3983b48d41f56a9ac17b2ecf31af2a6dd.tar
data-service-4710d4e3983b48d41f56a9ac17b2ecf31af2a6dd.tar.gz
Add a function to help parse PostgreSQL arrays
-rw-r--r--guix-data-service/model/utils.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/guix-data-service/model/utils.scm b/guix-data-service/model/utils.scm
index 7798e74..a1cd432 100644
--- a/guix-data-service/model/utils.scm
+++ b/guix-data-service/model/utils.scm
@@ -11,6 +11,7 @@
non-empty-string-or-false
exec-query->vhash
two-lists->vhash
+ parse-postgresql-array-string
deduplicate-strings
group-list-by-first-n-fields
insert-missing-data-and-return-all-ids))
@@ -47,6 +48,15 @@
l1
l2))
+(define (parse-postgresql-array-string s)
+ (if (string=? s "{}")
+ '()
+ (string-split
+ (string-drop-right
+ (string-drop s 1)
+ 1)
+ #\,)))
+
(define (deduplicate-strings strings)
(pair-fold
(lambda (pair result)