X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=base%2Futils.cl;h=de028aaf6e4cfcd238a84ae70f3ec144dcbe2699;hb=72f0ea8c6db74bd59809a9cd427969e85bfa0a78;hp=b64824c971b29a61d858280eb1c664cd5f15b57d;hpb=04a4f10a13773101f275c31f300b28c08be652c0;p=clsql.git diff --git a/base/utils.cl b/base/utils.cl index b64824c..de028aa 100644 --- a/base/utils.cl +++ b/base/utils.cl @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Mar 2002 ;;;; -;;;; $Id: utils.cl,v 1.2 2002/05/15 17:23:59 kevin Exp $ +;;;; $Id: utils.cl,v 1.3 2002/05/19 16:05:22 kevin Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -32,8 +32,24 @@ "Convert exponent character for SQL" (substitute #\e #\f (substitute #\e #\d (write-to-string num :readably t)))) -(defun sql-escape (s) - "Escape single quotes for SQL" +(defun sql-escape (identifier) + "Change hyphens to underscores, ensure string" + (let* ((unescaped (etypecase identifier + (symbol (symbol-name identifier)) + (string identifier))) + (escaped (make-string (length unescaped)))) + (dotimes (i (length unescaped)) + (setf (char escaped i) + (cond ((equal (char unescaped i) #\-) + #\_) + ;; ... + (t + (char unescaped i))))) + escaped)) + + +(defun sql-escape-quotes (s) + "Escape quotes for SQL string writing" (substitute-string-for-char s #\' "''")) (defun substitute-string-for-char (procstr match-char subst-str)