more on storage/tracking: start constructing SQL with sxql
This commit is contained in:
parent
bf114841ca
commit
c5c6a0bc7f
3 changed files with 33 additions and 15 deletions
|
@ -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)))
|
||||||
|
|
|
@ -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)
|
|
||||||
(time-stamp :reader time-stamp :accessor time-stamp!)
|
|
||||||
(data :accessor data)
|
|
||||||
(container :initarg :container :initform nil)))
|
|
||||||
|
|
||||||
|
(defclass track ()
|
||||||
|
((head)
|
||||||
|
(time-stamp :reader time-stamp :accessor time-stamp!)
|
||||||
|
(data :accessor data :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)))))
|
||||||
|
|
|
@ -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)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue