X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=base%2Fclasses.lisp;h=292bb6ba22b9804934877620acf2a4c72e363778;hp=f7a700e40b0389d9a6823f35084a4ac03f372d2c;hb=9bbed78051e80e6ab76ae47834136035602bbbf1;hpb=ce0e343835a040406678dff74a62d1b0cb56f317 diff --git a/base/classes.lisp b/base/classes.lisp index f7a700e..292bb6b 100644 --- a/base/classes.lisp +++ b/base/classes.lisp @@ -18,7 +18,7 @@ ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; ************************************************************************* -(in-package #:clsql-base-sys) +(in-package #:clsql-base) (defclass database () @@ -26,34 +26,29 @@ (connection-spec :initform nil :initarg :connection-spec :reader connection-spec :documentation "Require to use connection pool") + (database-type :initarg :database-type :initform :unknown + :reader database-type) + (state :initform :closed :reader database-state) (command-recording-stream :accessor command-recording-stream :initform nil) (result-recording-stream :accessor result-recording-stream :initform nil) + (query-recording-stream :accessor query-recording-stream :initform nil) (view-classes :accessor database-view-classes :initform nil) (schema :accessor database-schema :initform nil) (transaction-level :initform 0 :accessor transaction-level) (transaction :initform nil :accessor transaction) - (conn-pool :initform nil :initarg :conn-pool :accessor conn-pool)) + (conn-pool :initform nil :initarg :conn-pool :accessor conn-pool) + (attribute-cache :initform (make-hash-table :size 100 :test 'equal) + :accessor attribute-cache + :documentation "Internal cache of table attributes. It is keyed by table-name. Values +are a list of ACTION specified for table and any cached value of list-attributes-types.")) (:documentation "This class is the supertype of all databases handled by CLSQL.")) (defmethod print-object ((object database) stream) (print-unreadable-object (object stream :type t :identity t) - (write-string (if (slot-boundp object 'name) - (database-name object) - "") - stream))) - -;; Closed database idea and original code comes from UncommonSQL - -(defclass closed-database () - ((name :initarg :name :reader database-name)) - (:documentation - "This class represents databases after they are closed via 'disconnect'.")) - -(defmethod print-object ((object closed-database) stream) - (print-unreadable-object (object stream :type t :identity t) - (write-string (if (slot-boundp object 'name) - (database-name object) - "") - stream))) + (format stream "~A ~A" + (if (slot-boundp object 'name) + (database-name object) + "") + (database-state object))))