r11336: fix sql
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sat, 9 Dec 2006 23:50:04 +0000 (23:50 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sat, 9 Dec 2006 23:50:04 +0000 (23:50 +0000)
classes.lisp
sql-classes.lisp

index efa685feab503a063bbe5e03b58d5eb8964cd77b..996a7cdde8bb2f781a23b38aabee46443dabad03 100644 (file)
    (saui :value-type string :initarg :saui :reader saui)
    (sdui :value-type string :initarg :sdui :reader sdui)
    (scui :value-type string :initarg :scui :reader scui)
-   (tty :value-type string :initarg :tty :reader tty :hyperlink find-btty-tty)
+   (tty :value-type string :initarg :tty :reader tty)
    (code :value-type string :initarg :code :reader code)
    (sab :value-type string :initarg :sab :reader sab :hyperlink find-usab-rsab)
    (lat :value-type string :initarg :lat :reader lat)
index 66e2cbbb2d47ed01efba94ce341f73c34dc932b1..a407364012b868e02371b61856717e7e7c2a2f07 100644 (file)
@@ -65,7 +65,7 @@
         ,@(when %%order (list %%order))
         (cond
          ((and ,%single ,%limit)
-          (error "Can't set single and limit"))
+          (error  "Can't set single (~S) and limit (~S)" ,%single ,%limit))
          (,%single
           " LIMIT 1")
          (,%limit
@@ -744,17 +744,17 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS"
   (let ((query (format nil "SELECT c.cui FROM MRCONSO c,MRXW_ENG x WHERE x.WD  ~A '~A' AND x.cui=c.cui AND ~A ~A"
                        (if like "LIKE" "=")
                        (clsql-sys::sql-escape-quotes word)
-                       (typecase sab
+                       (etypecase sab
                          (string 
-                          (format nil " c.sab='" (clsql-sys::sql-escape-quotes sab)))
+                          (format nil " c.sab='~A'" (clsql-sys::sql-escape-quotes sab)))
                          (cons
-                          (format nil " c.sab IN (~('~A'~^,~))"
+                          (format nil " c.sab IN (~{'~A'~^,~})"
                                   (mapcar 'clsql-sys::sql-escape-quotes sab)))
-                         (t
+                         (null
                           (error "SAB missing")))
                        (if srl (format nil "AND KCUILRL <= ~A" srl) ""))))
     (loop for tuple in (mutex-sql-query query)
-          collect (make-instance 'ucon (first tuple)))))
+          collect (make-instance 'ucon :cui (first tuple)))))
 
 (defun find-ustr-word-sab (word &key sab (srl *current-srl*) (like nil))
   "Return list of ustr that match word in matching SAB. Optionally, use SQL's LIKE syntax"
@@ -1092,25 +1092,3 @@ is OBJNAME from TABLE where WHERE-NAME field = WHERE-VALUE with FIELDS"
   (collect-umlisp-query (ustats (name count) nil srl srl :order (name asc))
                           (make-instance 'ustats :name name :hits (ensure-integer count))))
 
-
-
-(defun find-bsab-sab (sab)
- (collect-umlisp-query (bonus_sab (name count) nil sab sab :single t)
-     (make-instance 'bsab :sab sab :name name :hits (ensure-integer count))))
-
-(defun find-bsab-all ()
- (collect-umlisp-query (bonus_sab (sab name count) nil nil nil :order (sab asc))
-     (make-instance 'bsab :sab sab :name name :hits (ensure-integer count))))
-
-(defun find-btty-tty (tty)
- (collect-umlisp-query (bonus_tty (name count) nil tty tty :single t)
-     (make-instance 'btty :tty tty :name name :hits (ensure-integer count))))
-
-(defun find-btty-all ()
- (collect-umlisp-query (bonus_tty (tty name count) nil nil nil :order (tty asc))
-  (make-instance 'btty :tty tty :name name :hits (ensure-integer count))))
-
-(defun find-brel-rel (rel)
-  (collect-umlisp-query (bonus_rel (sab sl rel rela count) nil rel rel)
-    (make-instance 'brel :sab sab :sl sl :rel rel :rela rela
-                   :hits (ensure-integer count))))