plist version of sql-insert

This commit is contained in:
David Botton 2022-02-20 19:43:14 -05:00
parent 52cdb8cf20
commit dafb77bc12
2 changed files with 15 additions and 3 deletions

View file

@ -25,14 +25,14 @@ TEXT-VALUE is set, if not the slot is set to the value. If key is not
the name of a slot it is ignored. The key is coverted to a string and
upper cased before attempting to match it to a slot if :UPCASE-KEY t
(default)."
(loop for (key value) on plist by #'cddr while value
(loop for (key value) on plist by #'cddr while value
do
(let* ((slot-str (format nil "~A" key))
(slot-name (if upcase-key
(string-upcase slot-str)
slot-str)))
(when (find-symbol slot-name)
(let ((slot-sym (intern slot-name)))
(let ((slot-sym (intern slot-name)))
(when (slot-exists-p obj slot-sym)
(if (and (slot-boundp obj slot-sym)
(typep (slot-value obj slot-sym) 'clog:clog-element))
@ -148,7 +148,7 @@ SQL update. If a value is a string it is quoted with single quotes
(and single quotes qutoed by doubling) unless is the single
character '?'."
(let ((result))
(loop for (key value) on plist by #'cddr while value
(loop for (key value) on plist by #'cddr while value
do
(push (format nil "~A = ~A~A"
key
@ -189,6 +189,17 @@ character '?'."
(sql-field-list field-list)
(sql-value-list value-list)))
;;;;;;;;;;;;;;;;;
;; sql-insert* ;;
;;;;;;;;;;;;;;;;;
(defun sql-insert* (table plist)
"Build basic sql insert statement using a plist"
(loop for (key value) on plist by #'cddr while value
collect key into fields
collect value into values
finally (return (sql-insert table fields values))))
;;;;;;;;;;;;;;;;
;; sql-update ;;
;;;;;;;;;;;;;;;;

View file

@ -534,6 +534,7 @@ embedded in a native template application.)"
(sql-update-list function)
(sql-select function)
(sql-insert function)
(sql-insert* function)
(sql-update function))
(defsection @clog-panels (:title "CLOG Panels")