From 281e4591900247c02cf94a169d1d74f589a0282b Mon Sep 17 00:00:00 2001 From: Maciej Pasternacki Date: Sun, 12 Apr 2009 14:29:54 +0200 Subject: [PATCH] - docfix - purge empty deleted terms in (SETF ITEM-TERMS) --- src/taxonomy.lisp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/taxonomy.lisp b/src/taxonomy.lisp index bccb8d6..df92e5a 100644 --- a/src/taxonomy.lisp +++ b/src/taxonomy.lisp @@ -340,10 +340,7 @@ not present before." :none)) (defun unbind-term (item term) - "Deletes association between ITEM and TERM. - -If PURGE-EMPTY is non-NIL (default), deletes also from TERM table if -no more items refer to this term." + "Deletes association between ITEM and TERM." (execute (:delete-from 'item-term :where (:and (:= 'item-id (id item)) (:= 'term-id (id term))))) @@ -381,7 +378,10 @@ added terms to NULL." (when ids-to-del (execute (:delete-from 'item-term :where (:and (:= 'item-id (id item)) - (:in 'term-id (:set ids-to-del)))))) + (:in 'term-id (:set ids-to-del))))) + (execute (:delete-from 'term :where (:and (:in 'term-id (:set ids-to-del)) + (:not (:exists (:select '* :from 'item-term + :where (:= 'item-term.term-id 'term.term-id)))))))) (when ids-to-add (execute (:insert-rows-into 'item-term :columns 'item-id 'term-id -- 2.11.4.GIT