more on storage/tracking: start constructing SQL with sxql

This commit is contained in:
Helmut Merz 2024-05-05 22:25:42 +02:00
parent bf114841ca
commit c5c6a0bc7f
3 changed files with 33 additions and 15 deletions

View file

@ -1,11 +1,14 @@
;;; cl-scopes/storage ;;; cl-scopes/storage/storage.lisp
;;;; Common layer for SQL storage functionality. ;;;; Common layer for SQL storage functionality.
(defpackage :scopes/storage (defpackage :scopes/storage
(:use :common-lisp) (:use :common-lisp)
(:export #:query (:export #:storage))
#:track #:time-stamp #:data))
(in-package :scopes/storage) (in-package :scopes/storage)
(defclass storage ()
((db :initarg :db)
(config :initarg :config)
(schema :initarg :schema)))

View file

@ -2,11 +2,26 @@
;;;; A simple generic (SQL-based) storage for tracks, messages, and other stuff. ;;;; A simple generic (SQL-based) storage for tracks, messages, and other stuff.
(in-package :scopes/storage) (defpackage :scopes/storage/tracking
(:use :common-lisp)
(:export #:track #:time-stamp #:data
#:container
#:crtable))
(defclass track () ( (in-package :scopes/storage/tracking)
(head)
(defclass track ()
((head)
(time-stamp :reader time-stamp :accessor time-stamp!) (time-stamp :reader time-stamp :accessor time-stamp!)
(data :accessor data) (data :accessor data :initform nil)
(container :initarg :container :initform nil))) (container :initarg :container)))
(defclass container ()
((storage :initarg :storage)))
(defun crtable (tn)
(sxql:yield
(sxql:make-statement :create-table tn
(list
(list 'trackid :type 'bigserial :primary-key t)
(list 'taskid :type 'text)))))

View file

@ -4,18 +4,18 @@
(defpackage :scopes/test-storage (defpackage :scopes/test-storage
(:use :common-lisp) (:use :common-lisp)
(:local-nicknames (:scs :scopes/storage) (:local-nicknames (:tracking :scopes/storage/tracking)
(:sct :scopes/testing)) (:t :scopes/testing))
(:export #:run)) (:export #:run))
(in-package :scopes/test-storage) (in-package :scopes/test-storage)
(defun run () (defun run ()
(let ((tst (sct:test-suite))) (let ((tst (t:test-suite)))
(test-track tst) (test-track tst)
(sct:result tst))) (t:result tst)))
(defun test-track (tst) (defun test-track (tst)
(let ((tr (make-instance 'scs:track))) (let ((tr (make-instance 'tracking:track)))
;(setf (scs:data tr) nil) ;(setf (scs:data tr) nil)
(sct:assert-eq tst (scs:data tr) nil))) (t:assert-eq tst (tracking:data tr) nil)))