X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Ffdml.lisp;h=943a1577ccf3538e50261e4db344d9029706cff3;hp=ee9a37db3ea0a343eb0b1ba33e8fbe49b8a4a955;hb=e15b72fefebeee46a83d357db2813031edcc6fbd;hpb=cb683851a0af33e88b7c4995435dc0cf226f6cba diff --git a/sql/fdml.lisp b/sql/fdml.lisp index ee9a37d..943a157 100644 --- a/sql/fdml.lisp +++ b/sql/fdml.lisp @@ -192,116 +192,6 @@ are nil and AV-PAIRS is an alist of (attribute value) pairs." (execute-command stmt :database database))) -;; output-sql - -(defmethod database-output-sql ((str string) database) - (declare (ignore database) - (optimize (speed 3) (safety 1) #+cmu (extensions:inhibit-warnings 3)) - (type (simple-array * (*)) str)) - (let ((len (length str))) - (declare (type fixnum len)) - (cond ((= len 0) - +empty-string+) - ((and (null (position #\' str)) - (null (position #\\ str))) - (concatenate 'string "'" str "'")) - (t - (let ((buf (make-string (+ (* len 2) 2) :initial-element #\'))) - (do* ((i 0 (incf i)) - (j 1 (incf j))) - ((= i len) (subseq buf 0 (1+ j))) - (declare (type integer i j)) - (let ((char (aref str i))) - (cond ((eql char #\') - (setf (aref buf j) #\\) - (incf j) - (setf (aref buf j) #\')) - ((eql char #\\) - (setf (aref buf j) #\\) - (incf j) - (setf (aref buf j) #\\)) - (t - (setf (aref buf j) char)))))))))) - -(let ((keyword-package (symbol-package :foo))) - (defmethod database-output-sql ((sym symbol) database) - (convert-to-db-default-case - (if (equal (symbol-package sym) keyword-package) - (concatenate 'string "'" (string sym) "'") - (symbol-name sym)) - database))) - -(defmethod database-output-sql ((tee (eql t)) database) - (declare (ignore database)) - "'Y'") - -(defmethod database-output-sql ((num number) database) - (declare (ignore database)) - (princ-to-string num)) - -(defmethod database-output-sql ((arg list) database) - (if (null arg) - "NULL" - (format nil "(~{~A~^,~})" (mapcar #'(lambda (val) - (sql-output val database)) - arg)))) - -(defmethod database-output-sql ((arg vector) database) - (format nil "~{~A~^,~}" (map 'list #'(lambda (val) - (sql-output val database)) - arg))) - -(defmethod database-output-sql ((self wall-time) database) - (declare (ignore database)) - (db-timestring self)) - -(defmethod database-output-sql ((self duration) database) - (declare (ignore database)) - (format nil "'~a'" (duration-timestring self))) - -(defmethod database-output-sql (thing database) - (if (or (null thing) - (eq 'null thing)) - "NULL" - (error 'sql-user-error - :message - (format nil - "No type conversion to SQL for ~A is defined for DB ~A." - (type-of thing) (type-of database))))) - - -(defmethod output-sql-hash-key ((arg vector) database) - (list 'vector (map 'list (lambda (arg) - (or (output-sql-hash-key arg database) - (return-from output-sql-hash-key nil))) - arg))) - -(defmethod output-sql (expr database) - (write-string (database-output-sql expr database) *sql-stream*) - (values)) - -(defmethod output-sql ((expr list) database) - (if (null expr) - (write-string +null-string+ *sql-stream*) - (progn - (write-char #\( *sql-stream*) - (do ((item expr (cdr item))) - ((null (cdr item)) - (output-sql (car item) database)) - (output-sql (car item) database) - (write-char #\, *sql-stream*)) - (write-char #\) *sql-stream*))) - t) - -#+nil -(defmethod add-storage-class ((self database) (class symbol) &key (sequence t)) - (let ((tablename (view-table (find-class class)))) - (unless (tablep tablename) - (create-view-from-class class) - (when sequence - (create-sequence-from-class class))))) - - ;;; Iteration (defmacro do-query (((&rest args) query-expression