Bug in sequence names was reported by Jan Tolenaar.
authorRuss Tyndall <russ@acceleration.net>
Wed, 28 Mar 2012 18:11:22 +0000 (14:11 -0400)
committerRuss Tyndall <russ@acceleration.net>
Wed, 28 Mar 2012 18:11:22 +0000 (14:11 -0400)
We changed the naming scheme inadvertently.  Added a flag
*old-sequence-names* to force use of the old naming scheme.  Hopefully
this will not break for anyone relying on the new naming scheme

ChangeLog
sql/package.lisp
sql/sequences.lisp

index 37b7154f9eb032032f9ed42374c530b44e446302..97264eb113e34e5a564469b806b398d7dfb3560f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-03-28  Russ Tyndall <russ@acceleration.net>
+
+        * sql/sequences.lisp: [A Patch FROM 2011-07-28 changed sequences.
+       They were previously prefixed with _CLSQL_SEQ_ but are now
+       suffixed with _CLSQL_SEQ. This is likely to break existing
+       implementations using the default sequence names
+
+       setting *old-sequence-names* to T, should force using the older
+       naming scheme
+
 2012-03-27  Ryan Davis  <ryan@acceleration.net>
 
        * sql/expressions.lisp: Fixed bug with subqueries in the where
        * test/: Better, more tests, better type coercion in tests and
        throughout (%get-int)
 
+       [edit 2012-03-28 - RT]
+       * sql/sequences.lisp: Sequences were previously prefixed with
+       _CLSQL_SEQ_ but are now suffixed with _CLSQL_SEQ. This is likely
+       to break existing implementations using the default sequence names
+
+       setting *old-sequence-names* to T, should force using the older
+       naming scheme
+
 
 2011-07-16  Kevin Rosenberg <kevin@rosenberg.net>
        * Version 5.4.0 release
index f922b18135132f5836021248e697860447ae3513..eb5b0ed46282984b0c64420642daee9f48fbf413 100644 (file)
          #:sequence-next
          #:sequence-last
          #:set-sequence-position
+         #:*old-sequence-names*
 
          ;; FDML (fdml.lisp)
          #:select
index 3e9a2e4816f4440d6a34bcefff481ac48381268f..1b32f29b2056b0cdeaae4579080dee3ce6446e01 100644 (file)
 
 ;;; Sequence functions
 
+(defvar *old-sequence-names* nil
+  "Should CLSQL use its old sequence naming scheme _CLSQL_SEQ_{table} instead
+   of the current scheme {table}_CLSQL_SEQ")
+
 (defun %sequence-name-to-table (sequence-name database)
   (escaped
    (combine-database-identifiers
-    (list sequence-name 'CLSQL_SEQ)
+    (if *old-sequence-names*
+        (list '_CLSQL_SEQ sequence-name)
+        (list sequence-name 'CLSQL_SEQ))
     database)))
 
 (defmethod database-create-sequence (sequence-name database)
    (concatenate 'string "DROP TABLE " (%sequence-name-to-table sequence-name database))
    database))
 
+(defun %seq-name-key ()
+  (if *old-sequence-names*
+      "_CLSQL_SEQ_"
+      "_CLSQL_SEQ"))
+
 (defun %table-name-to-sequence-name (table-name)
   ;; if this was escaped it still should be,
   ;; if it wasnt it still shouldnt-be
   (check-type table-name string)
-  (replace-all table-name "_CLSQL_SEQ" ""))
+  (replace-all table-name (%seq-name-key) ""))
 
 (defmethod database-list-sequences (database &key (owner nil))
   (declare (ignore owner))
   (mapcan #'(lambda (s)
-              (and (search "_CLSQL_SEQ" s :test #'string-equal)
+              (and (search (%seq-name-key) s :test #'string-equal)
                    (list (%table-name-to-sequence-name s))))
           (database-list-tables-and-sequences database)))