aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/model/utils.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix-data-service/model/utils.scm')
-rw-r--r--guix-data-service/model/utils.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/guix-data-service/model/utils.scm b/guix-data-service/model/utils.scm
index 0ce9fea..a7443d6 100644
--- a/guix-data-service/model/utils.scm
+++ b/guix-data-service/model/utils.scm
@@ -1,10 +1,12 @@
(define-module (guix-data-service model utils)
#:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
#:use-module (ice-9 vlist)
#:use-module (ice-9 receive)
#:use-module (squee)
#:export (quote-string
value->quoted-string-or-null
+ value->sql-boolean
non-empty-string-or-false
exec-query->vhash
two-lists->vhash
@@ -19,6 +21,16 @@
(string-append "$STR$" value "$STR$")
"NULL"))
+(define (value->sql-boolean v)
+ (match v
+ ((? boolean? x)
+ (if x "TRUE" "FALSE"))
+ ((? string? x)
+ (if (or (string=? x "t")
+ (string=? x "TRUE"))
+ "TRUE"
+ "FALSE"))))
+
(define (non-empty-string-or-false s)
(if (string? s)
(if (string-null? s)