New release 5.2.0 debian-5.2.0-1 v5.2.0
authorKevin Rosenberg <kevin@rosenberg.net>
Sun, 7 Nov 2010 16:48:18 +0000 (09:48 -0700)
committerKevin Rosenberg <kevin@rosenberg.net>
Sun, 7 Nov 2010 16:48:18 +0000 (09:48 -0700)
* 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.

ChangeLog
db-odbc/odbc-api.lisp
debian/changelog
sql/expressions.lisp
tests/test-syntax.lisp

index 0cf32cf11a4a58ffdff103108259b8da57468130..6223fd7392a18e3a58853318d59e087f4a759f35 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+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
index 2f200ca7db40e4da0bc95be08d64a31cb22d3275..92e7607c221d313fbd77986e7ba69c06ce5826be 100644 (file)
@@ -919,7 +919,7 @@ as possible second argument) to the desired representation of date/time/timestam
                          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))
index c0d3a4932a7a115c74cd19030366bd02c7323ceb..6281831a55c8f250df356339655d04bd4cb81c90 100644 (file)
@@ -1,3 +1,9 @@
+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
index 7389d1c06470690d04943ffa8b077d8bf1cb08e2..5e75b01ccdfaaae1842dabe6dea7179cb77674e0 100644 (file)
     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)
index 65efd9830bf414e2ede51e8290e6c9720a8d0ce7..6cb1c0c1ce1d26df8a76f39b4ba234d18fd23673 100644 (file)
 
 ))
 
+(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)