Commit c1d47ca3 authored by ryszard.szopa's avatar ryszard.szopa
Browse files

DAO conditions.

darcs-hash:ad79151ef080b8ef01a3e874843ebcf36a7cf1f0
parent 957330ac
......@@ -2,6 +2,17 @@
(in-package :submarine)
;; DAO conditions
(define-condition dao-error (simple-error)
((type :initarg :type :reader table-name))
(:documentation "Base class for DAO related errors."))
(define-condition dao-nonexistent-id (dao-error)
((id :initarg :id :reader id))
(:documentation "Condition signaling the attempt to initialize a dao
with a non-existant ID."))
;;
;; DAO
;;
......@@ -82,9 +93,9 @@ any)."
:where (:= 'id (get-id dao))) :alist)))
(unless query-result
(error (make-condition
'sql-id-does-not-exist
'dao-nonexistent-id
:format-control "You tried to create a DAO with a non-existant ID."
:id (get-id dao) :table (class-name-of dao))))
:id (get-id dao) :type (class-name-of dao))))
(iter
(for slot in (non-transient-slots-of dao))
......@@ -196,4 +207,5 @@ The connection-spec is taken from class1."
(link (intern (format nil "~A-~A" type1 type2))))
(save-dao (make-instance link
(intern (symbol-name type1 'keyword)) object1
(intern (symbol-name type2 'keyword)) object2)))))
\ No newline at end of file
(intern (symbol-name type2 'keyword)) object2)))))
......@@ -99,11 +99,6 @@ right name in the table, but its type is wrong"))
(type :initarg :type :reader column-type))
(:documentation "Condition signaling a missing column in an existing table."))
(define-condition sql-id-does-not-exist (sql-error)
((id :initarg :id :reader id))
(:documentation "Condition signaling the attempt to initialize a dao
with a non-existant ID."))
(defgeneric database-consistent-with-specification (class)
(:documentation "Return nothing if TABLE in the connected-p database
meets its specification. Otherwise, throw an appropriate error. There
......
......@@ -7,7 +7,7 @@
(:documentation "A very simple quasi-object persistency system built on top of Postmodern.")
(:export
#:db-class #:foreign-type-p #:defdao
#:dao-nonexistent-id #:dao-error
#:class-name-of #:class-non-transient-slots #:slot-value-or-id-if-foreign
#:with-connection #:with-object-connection #:with-class-connection
......
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