I'm wanting to use the IF EXISTS modifier for the various DROP operations, and it seems like the semantics of CASCADE works best for this case.
The following is a proof of concept implementation. If there aren't any issues or complaints I'll write a patch that covers the rest of the DROP operations.
(defvar *expand-if-exists* nil)
(defun expand-if-exists () (when *expand-if-exists* `("IF EXISTS ")))
(def-sql-op :if-exists (op) (let ((*expand-if-exists* t)) (sql-expand op)))
(def-sql-op :drop-sequence (name) `("DROP SEQUENCE " ,@(expand-if-exists) ,@(sql-expand name)))
(sql (:if-exists (:drop-sequence 'sequence)))
Cheers,
Good suggestion, but I think the special variable thing is a bit more cognitive overload than it's worth. I just added an extra argument to all the :drop-... operators, and am now generating them through a macro. Pull from repository to see the change.
Best, Marijn
postmodern-devel@common-lisp.net