 	   }
 	   (data joined-model)))
 
-    ;; join - new lhs - a2
+    ;; join - delete lhs - a2
     (on-delete as a2)
     (is (= [[{:b {:a1 a1v1}}{:c {:a1 a1v1}}]
 	    {:b {:b1 b1v1 :b2 b2}} {:c {:c1 c1v1 :c2 c2}}] (data join)))

	   }
	   (data joined-model)))


    ;; TODO:
    ;;  amend in/out

    [new-indeces (fn [_] (on-upserts joined-model joins))]
    ))

;;; TODO - ugly, slow and should remove key rather than leaving a key:nil assoc...
(defn- rhs-delete [old-indeces i rhs-pk-key rhs-fk-key lhs-fk-keys rhs join-fn joined-model]
  (let [fk (rhs-fk-key rhs)
	old-rhs-indeces (rest old-indeces)
	lhs-indeces (first old-indeces)
	lhses (lhses-get lhs-indeces (dec i) fk)
	old-joins (mapcat (fn [lhs] (derive-joins old-rhs-indeces lhs-fk-keys lhs join-fn)) lhses)
	new-indeces (rhs-dissoc old-indeces i rhs-pk-key fk rhs)
	new-rhs-indeces (rest new-indeces)
	new-joins (mapcat (fn [lhs] (derive-joins new-rhs-indeces lhs-fk-keys lhs join-fn)) lhses)
	joins (remove (fn [i] (contains? (apply hash-set new-joins) i)) old-joins)
	]
    [new-indeces (fn [_] (on-deletes joined-model joins))]
    ))

;;; TODO
(defn- rhs-upserts [old-indeces i ks vs join-fn])
(defn- rhs-deletes [old-indeces i ks vs join-fn])

