From: Kevin M. Rosenberg Date: Sat, 9 Dec 2006 23:50:04 +0000 (+0000) Subject: r11336: fix sql X-Git-Tag: v2006ac.2~43 X-Git-Url: http://git.kpe.io/?p=umlisp.git;a=commitdiff_plain;h=4d8d4c6285b12f05be8de7735af7a34d4fca85e4 r11336: fix sql --- diff --git a/classes.lisp b/classes.lisp index efa685f..996a7cd 100644 --- a/classes.lisp +++ b/classes.lisp @@ -158,7 +158,7 @@ (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) diff --git a/sql-classes.lisp b/sql-classes.lisp index 66e2cbb..a407364 100644 --- a/sql-classes.lisp +++ b/sql-classes.lisp @@ -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))))