[patch] with-database bug
Chaitanya Gupta <[email protected]> Sat, 26 May 2007 13:21:37 +0530
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------010507090707010405000902
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
This patch is for the bug reported in
http://lists.b9.com/pipermail/clsql-help/2007-May/000823.html
Even if its not considered a bug, at the very least, this behaviour of
with-database is very surprising.
This patch makes sure that in WITH-DATABASE, the default value of
MAKE-DEFAULT is NIL when CONNECT is called. I am not sure if this is the
right way to fix this bug, but since the original post received no
response, I am posting this. Hopefully it will be fixed soon.
Thanks,
Chaitanya
--------------010507090707010405000902
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="database.lisp.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="database.lisp.patch"
--- clsql-3.8.3/sql/database.lisp.orig 2007-05-19 01:20:07.000000000 +0530
+++ clsql-3.8.3/sql/database.lisp 2007-05-19 01:35:31.000000000 +0530
@@ -307,6 +307,20 @@
(setq connection-spec (string-to-list-connection-spec connection-spec)))
(database-list connection-spec database-type))
+(defun connect-2 (connection-spec
+ &key (if-exists *connect-if-exists*)
+ (make-default nil)
+ (pool nil)
+ (database-type *default-database-type*))
+ "Just like CONNECT, except that MAKE-DEFAULT is NIL by default.
+This is to prevent WITH-DATABASE from assigning a connection to *DEFAULT-DATABASE*
+outside the scope of its body by default."
+ (connect connection-spec
+ :if-exists if-exists
+ :make-default make-default
+ :pool pool
+ :database-type database-type))
+
(defmacro with-database ((db-var connection-spec &rest connect-args) &body body)
"Evaluate the body in an environment, where DB-VAR is bound to the
database connection given by CONNECTION-SPEC and CONNECT-ARGS. The
@@ -314,7 +328,7 @@
from the body."
(let ((result (gensym "result-")))
(unless db-var (setf db-var '*default-database*))
- `(let ((,db-var (connect ,connection-spec ,@connect-args))
+ `(let ((,db-var (connect-2 ,connection-spec ,@connect-args))
(,result nil))
(unwind-protect
(let ((,db-var ,db-var))
--------------010507090707010405000902
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
CLSQL-Devel mailing list
[email protected]
http://lists.b9.com/mailman/listinfo/clsql-devel
--------------010507090707010405000902--