r4781: Auto commit for Debian build
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sat, 3 May 2003 22:45:23 +0000 (22:45 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sat, 3 May 2003 22:45:23 +0000 (22:45 +0000)
sql-classes.lisp

index 08ff59d05c06de6bc3c7d45d79461222af7cbb65..b6abb486af5d54d9da189699f14d2d8ed4d21bf8 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: sql-classes.lisp,v 1.54 2003/05/03 22:38:22 kevin Exp $
+;;;; $Id: sql-classes.lisp,v 1.55 2003/05/03 22:45:23 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
                                    &key (lrl "KCUILRL") distinct single
                                    order like)
                             &body body)
-  (if single
-    `(unless (and ,where-name (not ,where-value)) 
-      (let ((tuple (car (umlisp-query ,table ,fields ,srl ,where-name ,where-value
-                                     :lrl ,lrl :single ,single
-                                     :distinct ,distinct :order ,order :like ,like))))
-       (when tuple
-         (destructuring-bind ,fields tuple
-           ,@body))))
-    `(unless (and ,where-name (not ,where-value)) 
-      (loop for tuple in
-       (umlisp-query ,table ,fields ,srl ,where-name ,where-value
-       :lrl ,lrl :single ,single :distinct ,distinct :order ,order :like ,like)
-       collect (destructuring-bind ,fields tuple
-                ,@body)))))
+  (let ((value (gensym)))
+    (if single
+       `(let ((,value where-value))
+         (when ,value 
+           (let ((tuple (car (umlisp-query ,table ,fields ,srl ,where-name ,value
+                                           :lrl ,lrl :single ,single
+                                           :distinct ,distinct :order ,order
+                                           :like ,like))))
+             (when tuple
+               (destructuring-bind ,fields tuple
+                 ,@body)))))
+       `(let ((,value where-value))
+         (when ,value 
+           (loop for tuple in
+                 (umlisp-query ,table ,fields ,srl ,where-name ,value
+                               :lrl ,lrl :single ,single :distinct ,distinct
+                               :order ,order :like ,like)
+                 collect (destructuring-bind ,fields tuple
+                           ,@body)))))))
 
 (defmacro umlisp-query (table fields srl where-name where-value
                     &key (lrl "KCUILRL") single distinct order like)
   "Query the UMLisp database. Return a list of umlisp objects whose name
 is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS"
-  `(when (or (not ,where-name) ,where-value)
-    (mutex-sql-query
-     (query-string-macro ,table ,fields ,srl ,where-name ,where-value 
-      :lrl ,lrl :single ,single :distinct ,distinct :order ,order :like ,like))))
+  `(mutex-sql-query
+    (query-string-macro ,table ,fields ,srl ,where-name ,where-value 
+     :lrl ,lrl :single ,single :distinct ,distinct :order ,order :like ,like)))
 
   
 (defmacro query-string-macro (table fields &optional srl where-name where-value