X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/579597e310dfac262d629aade17f86c3d6b80da4..88dedfa8458d24bfc15eb6cbe62d472582ee8a7b:/src/meta-model.lisp diff --git a/src/meta-model.lisp b/src/meta-model.lisp index b0d1ff5..9065071 100644 --- a/src/meta-model.lisp +++ b/src/meta-model.lisp @@ -160,7 +160,9 @@ "returns the clsql view-class joined on SLOT" (dolist (s (list-join-attributes model)) (when (equal (getf (cdr s) :home-key) slot) - (return-from explode-foreign-key (slot-value model (car s)))))) + (let ((val (slot-value model (car s)))) + (return-from explode-foreign-key + (values (if val val (make-instance (getf (cdr s) :join-class))) (getf (cdr s) :foreign-key))))))) (defun find-join-helper (foreign-key) (lambda (class slot) @@ -175,5 +177,13 @@ "returns the SLOT in the foreign VIEW-CLASS that joins with FOREIGN-KEY" (car (list-relations-helper view (find-join-helper foreign-key) :return-key :foreign-key))) +(defmethod explode-has-many ((view t) join-slot) + "returns the class of the join as the primary value, the second and third value is the home key and the foreign key" + (let ((att (assoc join-slot (list-join-attributes view)))) + (values (getf (cdr att) :join-class) + (getf (cdr att) :home-key) + (getf (cdr att) :foreign-key)))) + +