+2010-10-24 Kevin Rosenberg <kevin@rosenberg.net>
+ * Version 5.2.0
+ * db-odbc/odbc-api.lisp: Change from SBCL-specific
+ to UFFI version of octets-to-strings. Reported by
+ Daniel Brunner <daniel@dbrunner.de>
+ * sql/oodml.lisp: Apply patch from Rupert Swarbrick
+ <rswarbrick@gmail.com>: Fix behaviour with auto-inc
+ primary keys.
+ * sql/expressions.lisp, tests/test-syntax.lisp: Apply
+ patch from Russ Tyndall to quote identifiers with space
+ or special character.
+
2010-09-20 Kevin Rosenberg <kevin@rosenberg.net>
* Version 5.1.4
* sql/{pool,database}.lisp: Pass encoding argument to
do
(setf res (%sql-get-data hstmt column-nr c-type data-ptr +max-precision+ out-len-ptr)
out-len (deref-pointer out-len-ptr #.$ODBC-LONG-TYPE)))
- (setf str (sb-ext:octets-to-string octets))
+ (setf str (uffi:octets-to-string octets))
(if (= sql-type $SQL_DECIMAL)
(let ((*read-base* 10))
(read-from-string str))
+cl-sql (5.2.0-1) unstable; urgency=low
+
+ * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org> Sun, 07 Nov 2010 09:47:02 -0700
+
cl-sql (5.1.4-1) unstable; urgency=low
* New upstream
sql
`(make-instance 'sql-ident-table :name ',name :table-alias ',alias)))
+(defun special-char-p (s)
+ "Check if a string has any special characters"
+ (loop for char across s
+ thereis (find char '(#\space #\, #\. #\! #\@ #\# #\$ #\%
+ #\^ #\& #\* #\| #\( #\) #\- #\+))))
+
(defmethod output-sql ((expr sql-ident-table) database)
(with-slots (name alias) expr
- (etypecase name
- (string
- (format *sql-stream* "~s" (sql-escape name)))
- (symbol
- (write-string (sql-escape name) *sql-stream*)))
- (when alias
- (format *sql-stream* " ~s" alias)))
+ (flet ((p (s) ;; the etypecase is in sql-escape too
+ (let ((sym? (symbolp s))
+ (s (sql-escape s)))
+ (format *sql-stream*
+ (if (and sym? (not (special-char-p s)))
+ "~a" "~s")
+ s))))
+ (p name)
+ (when alias
+ (princ #\space *sql-stream*)
+ (p alias))))
t)
(defmethod output-sql-hash-key ((expr sql-ident-table) database)
))
+(defun test-output-sql/sql-ident-table ()
+ (let ((tests `((,(make-instance 'sql-ident-table :name :foo) "FOO")
+ (,(make-instance 'sql-ident-table :name :foo-bar) "FOO_BAR")
+ (,(make-instance 'sql-ident-table :name "foo") "\"foo\"")
+ (,(make-instance 'sql-ident-table :name '|foo bar|) "\"foo bar\"")
+ (,(make-instance 'sql-ident-table :name :foo :table-alias :bar) "FOO BAR" )
+ (,(make-instance 'sql-ident-table :name :foo_bar :table-alias :bar-bast) "FOO_BAR BAR_BAST")
+ (,(make-instance 'sql-ident-table :name "foo" :table-alias "Bar") "\"foo\" \"Bar\"")
+ (,(make-instance 'sql-ident-table :name '|foo bar| :table-alias :bast) "\"foo bar\" BAST"))))
+ (loop for (test expected-result) in tests
+ for test-out = (with-output-to-string (*sql-stream*) (output-sql test nil))
+ do (assert (string-equal test-out expected-result)
+ (test test-out expected-result)
+ "Test:~s didnt match ~S"
+ test-out expected-result))))
+
#.(clsql:restore-sql-reader-syntax-state)