CLSQL with LW 5.1 problem
Hello, I'm using LWw 5.1 and has to change a declaration in the following CLSQL function (see #+:lispworks) because this error: Error: #\' is not of type simple-char. Looks like the compiler is too cautious. Notice using (safety 0) is working too. Francis (defmethod database-output-sql ((str string) database) (declare (optimize (speed 3) (safety 1) #+cmu (extensions:inhibit-warnings 3))) (let ((len (length str))) (declare (type fixnum len)) (cond ((zerop len) +empty-string+) ((and (null (position #\' str)) (null (position #\\ str))) (concatenate 'string "'" str "'")) (t (let ((buf (make-string (+ (* len 2) 2) :initial-element #\'))) #-:lispworks (declare (simple-string buf)) #+:lispworks (declare (string buf)) (do* ((i 0 (incf i)) (j 1 (incf j))) ((= i len) (subseq buf 0 (1+ j))) (declare (type fixnum i j)) (let ((char (aref str i))) (declare (character char)) (cond ((char= char #\') (setf (aref buf j) #\') (incf j) (setf (aref buf j) #\')) ((and (char= char #\\) ;; MTP: only escape backslash with pgsql/mysql (member (database-underlying-type database) '(:postgresql :mysql) :test #'eq)) (setf (aref buf j) #\\) (incf j) (setf (aref buf j) #\\)) (t (setf (aref buf j) char))))))))))