util:plist-equal (for tracking:save); work in progress: tracking:update; save: return track
This commit is contained in:
parent
bf48130837
commit
75fe19b269
3 changed files with 13 additions and 10 deletions
|
@ -70,15 +70,11 @@
|
|||
(found (query-last cont (shape:head-plist track))))
|
||||
(if (null found)
|
||||
(insert track new-data)
|
||||
(unless (plist-equal (shape:data found) new-data)
|
||||
(unless (util:plist-equal (shape:data found) new-data)
|
||||
(if (eql force-insert :changed)
|
||||
(insert track new-data)
|
||||
(update track new-data))))))))
|
||||
|
||||
(defun plist-equal (l1 l2)
|
||||
(util:lgi l1 l2)
|
||||
(equalp l1 l2))
|
||||
|
||||
(defun insert (track &optional data)
|
||||
(ensure-timestamp track)
|
||||
(let* ((cont (container track))
|
||||
|
@ -96,9 +92,10 @@
|
|||
(let* ((cont (container track))
|
||||
(st (storage cont))
|
||||
(table (storage:qualified-table-name st (table-name cont))))
|
||||
(sxql:update table
|
||||
(apply #'sxql:make-clause ':set= (plist track data))
|
||||
(where (:= :trackid (trackid track))))))
|
||||
(storage:do-sql st
|
||||
(sxql:update table
|
||||
(apply #'sxql:make-clause ':set= (plist track data))
|
||||
(where (:= :trackid (trackid track)))))))
|
||||
|
||||
;;;; auxiliary functions for queries, ...
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
(== (getf (shape:data pm2) :info) "test data")
|
||||
(setf pm3 (tracking:query-last cont '(:domain :test)))
|
||||
(util:lgi pm3)
|
||||
;(setf (getf (shape:data pm3) :info) "changed")
|
||||
(msgstore:save pm3 cont)
|
||||
(setf (getf (shape:data pm3) :info) "changed")
|
||||
(msgstore:save pm3 cont)
|
||||
))
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
(defpackage :scopes/util
|
||||
(:use :common-lisp)
|
||||
(:export #:lg #:lgd #:lgi
|
||||
#:rtrim #:loop-plist #:plist-pairs
|
||||
#:rtrim #:loop-plist #:plist-pairs #:plist-equal
|
||||
#:flatten-str #:to-keyword #:keyword-to-string #:to-string
|
||||
#:absolute-dir #:check-dir #:ensure-dir #:home-path #:path-from-string
|
||||
#:relative-path #:runtime-path #:system-path))
|
||||
|
@ -29,6 +29,11 @@
|
|||
(defun plist-pairs (pl)
|
||||
(loop-plist pl k v collect (list k v)))
|
||||
|
||||
(defun plist-equal (l1 l2)
|
||||
(loop-plist l1 k v do
|
||||
(unless (equal (getf l2 k) v)
|
||||
(return-from plist-equal nil)))
|
||||
t)
|
||||
;;;; strings, symbols, keywords, ...
|
||||
|
||||
(defun flatten-str (s &key (sep " "))
|
||||
|
|
Loading…
Add table
Reference in a new issue