Commit 320d6d4b authored by Dave Griffiths's avatar Dave Griffiths
Browse files

review convert/validate single ids

parent 06ecbda4
......@@ -179,7 +179,7 @@
(unique-id
(update-entity db table (entity-id-from-unique db table unique-id) (list ktv)))
(else
(msg "no values or no id to update as entity:" unique-id "values:" value)))))
(msg "no values or no id to update as entity:" unique-id "values:" ktv)))))
(define (entity-reset!)
......@@ -698,11 +698,34 @@
(string-append dirname "files/" image-name)))))
(else (msg "mupdate-widget unhandled widget type" widget-type))))
;(define (spinner-choice l i)
; (if (number? i)
; (symbol->string (list-ref l i))
; i))
;; spinner options are (list 'id-sym "Name") ...
(define (spinner-choice l i)
(if (number? i)
(symbol->string (list-ref l i))
(symbol->string (car (list-ref l i)))
i))
(define (spinner-index l s)
(define (_ l n s)
(cond
((null? l) 0)
((eq? (car (car l)) s) n)
((_ (cdr l) (+ n 1) s))))
(_ l 0 (string->symbol s)))
(define (spinner-index->name l i)
(define (_ l n)
(cond
((null? l) "Unknown")
((zero? n) (cadr (car l)))
((_ (cdr l) (- n 1)))))
(_ l i))
(define (mupdate-spinner id-symbol key choices)
(let* ((val (entity-get-value key)))
(if (not val)
......
This diff is collapsed.
......@@ -60,7 +60,7 @@
(else c)))
(string->list var))))
(define (build-query table filter)
(define (build-query table filter typed)
(string-append
(foldl
(lambda (i r)
......@@ -78,12 +78,13 @@
;; order by name
"join " table "_value_varchar "
"as n on n.entity_id = e.entity_id and n.attribute_id = 'name' "
;; ignore deleted
"join " table "_value_int "
;; ignore deleted (if exists)
"left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = 'deleted' and "
"d.value = 0 ")
"d.value = 0 or d.value = NULL ")
filter)
"where e.entity_type = ? order by n.value"))
(if typed "where e.entity_type = ? order by n.value"
"order by n.value")))
(define (build-args filter)
(map
......@@ -95,9 +96,9 @@
(let ((s (apply
db-select
(append
(list db (build-query table filter))
(list db (build-query table filter (not (equal? type "*"))))
(build-args filter)
(list type)))))
(if (equal? type "*") '() (list type))))))
(msg (db-status db))
(if (null? s)
'()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment