Skip to content

Commit

Permalink
Updated README, added option for avoiding error when calling print-ob…
Browse files Browse the repository at this point in the history
…ject
  • Loading branch information
html committed Jun 27, 2017
1 parent 8bd4f1c commit f870b98
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
This is a snapshot branch for users who wish to fetch the Fluid
backend separately from CLSQL. It does not include unit tests.

If you are interested in hacking this, please branch from Git branch
`fluid-pools' in git://repo.or.cz/clsql/s11.git . See more
If you are interested in hacking this, please branch from repository
https://github.com/html/clsql-fluid.git

Originally code copied from branch `fluid-pools' in git://repo.or.cz/clsql/s11.git .

More
information about this branch at

http://repo.or.cz/w/clsql/s11.git?a=shortlog;h=refs/heads/fluid-pools
Expand Down
20 changes: 20 additions & 0 deletions sql/fluid.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,25 @@ NEW-VALUE."
pool and forwards database API calls to the thread's backing
database connection."))

(defparameter *error-on-print-object-p* t
"Displays database object always, instead of throwing error in case of sql-database-error")

(defmethod print-object ((object fluid-database) stream)
(if *error-on-print-object-p*
(return-from print-object (call-next-method)))

(let* ((successp t)
(string (handler-case (with-output-to-string (s)
(call-next-method object s))
(sql-database-error (c)
(setf successp nil)
c))))
(if successp
(write-string string stream)
(print-unreadable-object (object stream :type t :identity t)
(format stream "\"~A\"" string))))
object)

(defmethod initialize-instance :after
((fd fluid-database) &key connection-spec database-type &allow-other-keys)
(setf (slot-value fd 'sub-pool)
Expand Down Expand Up @@ -246,5 +265,6 @@ positions specialized on `fluid-database', and NIL in other places."
;; If a DB interface function with a db-type or database parameter is
;; not mentioned above, it is a bug.
(export 'fluid-database)
(export '*error-on-print-object-p*)
(import 'fluid-database '#:clsql)
(export 'fluid-database '#:clsql)

0 comments on commit f870b98

Please sign in to comment.