X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Foodml.lisp;h=2a5b0510b849d5e92c84b626b110630588fc1c35;hb=0f82f4d309d861b377645694f2d3d8e5897b07bb;hp=30f6b0dfd82ea20aaab3526dcca657a8740f0a08;hpb=348cafca35b850b66b1181ba0661211e64f0d4f1;p=clsql.git diff --git a/sql/oodml.lisp b/sql/oodml.lisp index 30f6b0d..2a5b051 100644 --- a/sql/oodml.lisp +++ b/sql/oodml.lisp @@ -189,11 +189,14 @@ (db-value-from-slot slot val database)))) slots))) (cond ((and avps (view-database obj)) - (update-records (sql-expression :table vct) - :av-pairs avps - :where (key-qualifier-for-instance - obj :database database) - :database database)) + (let ((where (key-qualifier-for-instance + obj :database database))) + (unless where + (error "update-record-from-slots: Could not generate a where clause for this object: ~a" obj)) + (update-records (sql-expression :table vct) + :av-pairs avps + :where where + :database database))) ((and avps (not (view-database obj))) (insert-records :into (sql-expression :table vct) :av-pairs avps @@ -235,6 +238,7 @@ :result-types nil :database database))))) (when res + (setf (slot-value instance 'view-database) database) (get-slot-values-from-view instance (mapcar #'car sels) (car res))))) (defmethod update-slot-from-record ((instance standard-db-object) @@ -469,8 +473,12 @@ (format nil "~F" val))) (defmethod read-sql-value (val type database db-type) - (declare (ignore type database db-type)) - (read-from-string val)) + (declare (ignore database db-type)) + (cond + ((null type) val) ;;we have no desired type, just give the value + ((typep val type) val) ;;check that it hasn't already been converted. + ((typep val 'string) (read-from-string val)) ;;maybe read will just take care of it? + (T (error "Unable to read-sql-value ~a as type ~a" val type)))) (defmethod read-sql-value (val (type (eql 'string)) database db-type) (declare (ignore database db-type))