Add value->sql-boolean to (guix-data-service model utils)
This commit is contained in:
parent
66df42ae4f
commit
c7baf53c3f
1 changed files with 12 additions and 0 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
(define-module (guix-data-service model utils)
|
(define-module (guix-data-service model utils)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 vlist)
|
#:use-module (ice-9 vlist)
|
||||||
#:use-module (ice-9 receive)
|
#:use-module (ice-9 receive)
|
||||||
#:use-module (squee)
|
#:use-module (squee)
|
||||||
#:export (quote-string
|
#:export (quote-string
|
||||||
value->quoted-string-or-null
|
value->quoted-string-or-null
|
||||||
|
value->sql-boolean
|
||||||
non-empty-string-or-false
|
non-empty-string-or-false
|
||||||
exec-query->vhash
|
exec-query->vhash
|
||||||
two-lists->vhash
|
two-lists->vhash
|
||||||
|
|
@ -19,6 +21,16 @@
|
||||||
(string-append "$STR$" value "$STR$")
|
(string-append "$STR$" value "$STR$")
|
||||||
"NULL"))
|
"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)
|
(define (non-empty-string-or-false s)
|
||||||
(if (string? s)
|
(if (string? s)
|
||||||
(if (string-null? s)
|
(if (string-null? s)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue