;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: package.cl,v 1.3 2002/05/15 17:21:29 kevin Exp $
+;;;; $Id: package.cl,v 1.4 2002/05/19 16:05:22 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;; utils.cl
#:number-to-sql-string
#:float-to-sql-string
- #:sql-escape
+ #:sql-escape-quotes
;; For UncommonSQL support
#:sql-ident
;;;; 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
;;;;
"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)
;;;; Programmers: Kevin M. Rosenberg and onShore Development Inc
;;;; Date Started: Mar 2002
;;;;
-;;;; $Id: usql.cl,v 1.6 2002/04/07 15:11:21 kevin Exp $
+;;;; $Id: usql.cl,v 1.7 2002/05/19 16:05:23 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and onShore Development Inc
`(make-instance 'sql-ident :name ',name)))
-;; KMR -- change aref to more specific char
-(defun sql-escape (identifier)
- (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 create-sequence (name &key (database *default-database*))
(database-create-sequence name database))