From: Kevin Rosenberg Date: Sun, 7 Nov 2010 16:48:18 +0000 (-0700) Subject: New release 5.2.0 X-Git-Tag: v5.2.0^0 X-Git-Url: http://git.kpe.io/?p=clsql.git;a=commitdiff_plain;h=95704a836b85f40018186f97b332fd3873168a53 New release 5.2.0 * Version 5.2.0 * db-odbc/odbc-api.lisp: Change from SBCL-specific to UFFI version of octets-to-strings. Reported by Daniel Brunner * sql/oodml.lisp: Apply patch from Rupert Swarbrick : 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. --- diff --git a/ChangeLog b/ChangeLog index 0cf32cf..6223fd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-10-24 Kevin Rosenberg + * Version 5.2.0 + * db-odbc/odbc-api.lisp: Change from SBCL-specific + to UFFI version of octets-to-strings. Reported by + Daniel Brunner + * sql/oodml.lisp: Apply patch from Rupert Swarbrick + : 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 * Version 5.1.4 * sql/{pool,database}.lisp: Pass encoding argument to diff --git a/db-odbc/odbc-api.lisp b/db-odbc/odbc-api.lisp index 2f200ca..92e7607 100644 --- a/db-odbc/odbc-api.lisp +++ b/db-odbc/odbc-api.lisp @@ -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)) diff --git a/debian/changelog b/debian/changelog index c0d3a49..6281831 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-sql (5.2.0-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Sun, 07 Nov 2010 09:47:02 -0700 + cl-sql (5.1.4-1) unstable; urgency=low * New upstream diff --git a/sql/expressions.lisp b/sql/expressions.lisp index 7389d1c..5e75b01 100644 --- a/sql/expressions.lisp +++ b/sql/expressions.lisp @@ -192,15 +192,25 @@ 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) diff --git a/tests/test-syntax.lisp b/tests/test-syntax.lisp index 65efd98..6cb1c0c 100644 --- a/tests/test-syntax.lisp +++ b/tests/test-syntax.lisp @@ -409,4 +409,20 @@ )) +(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)