r4793: Auto commit for Debian build
[umlisp.git] / sql-classes.lisp
index 7c685a387e590962a3ceb9c584bf5358fc8b9786..086b5cdfe749f3c5ae6ad2de98328c3be7ced700 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:        Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: sql-classes.lisp,v 1.62 2003/05/04 01:18:58 kevin Exp $
+;;;; $Id: sql-classes.lisp,v 1.67 2003/05/04 01:42:20 kevin Exp $
 ;;;;
 ;;;; This file, part of UMLisp, is
 ;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
@@ -77,7 +77,6 @@
                            ,@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
@@ -103,15 +102,23 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS"
         (%%lrl (format nil " and ~:@(~A~)<=" lrl))
         (%%where (when where-name
                    (format nil " where ~:@(~A~)~A" where-name
-                         (if like " like " "=")))))
+                         (if like " like " "")))))
     `(concatenate
       'string
       ,%%fields
       ,@(when %%where (list %%where))
       ,@(when %%where
+             #+ignore
              `((if (numberp ,where-value)
                    (write-to-string ,where-value)
-                   (format nil ,(if like "'%~A%'" "'~A'") ,where-value))))
+                   (format nil ,(if like "'%~A%'" "'~A'") ,where-value)))
+             `((typecase ,where-value
+                 (number
+                  (concatenate 'string "=" (write-to-string ,where-value)))
+                 (null
+                  " is null")
+                 (t
+                  (format nil ,(if like "'%~A%'" "'=~A'") ,where-value)))))
       (if ,srl (concatenate 'string ,%%lrl (write-to-string ,srl)) "")
       ,@(when %%order (list %%order))
       ,@(when single (list " limit 1")))))