r10110: Automated commit for Debian build of clsql upstream-version-3.0.11
[clsql.git] / sql / oodml.lisp
index c98342ed55ddf3ce220ec7c5d9ddf86ad3c8ff4d..9d8154f44b6a0c6ea72c8c013d825884351f92dd 100644 (file)
   "INT")
 
 (deftype smallint () 
-  "An integer smaller than a 32-bit integer, this width may vary by SQL implementation."
+  "An integer smaller than a 32-bit integer. this width may vary by SQL implementation."
   'integer)
 
 (defmethod database-get-type-specifier ((type (eql 'smallint)) args database db-type)
   (declare (ignore args database db-type))
   "INT")
 
+(deftype mediumint () 
+  "An integer smaller than a 32-bit integer, but may be larger than a smallint. This width may vary by SQL implementation."
+  'integer)
+
+(defmethod database-get-type-specifier ((type (eql 'mediumint)) args database db-type)
+  (declare (ignore args database db-type))
+  "INT")
+
 (deftype bigint () 
   "An integer larger than a 32-bit integer, this width may vary by SQL implementation."
   'integer)
@@ -743,7 +751,8 @@ maximum of MAX-LEN instances updated in each query."
         (jc (gethash :join-class dbi)))
     (let ((jq (join-qualifier class object slot-def)))
       (when jq 
-        (select jc :where jq :flatp t :result-types nil)))))
+        (select jc :where jq :flatp t :result-types nil
+               :database (view-database object))))))
 
 (defun fault-join-slot (class object slot-def)
   (let* ((dbi (view-class-slot-db-info slot-def))
@@ -984,6 +993,10 @@ maximum of MAX-LEN instances updated in each query."
 
 (defmethod instance-refreshed ((instance standard-db-object)))
 
+(defvar *default-caching* t
+  "Controls whether SELECT caches objects by default. The CommonSQL
+specification states caching is on by default.")
+
 (defun select (&rest select-all-args) 
    "Executes a query on DATABASE, which has a default value of
 *DEFAULT-DATABASE*, specified by the SQL expressions supplied
@@ -1042,7 +1055,7 @@ as elements of a list."
        
        (cond
          ((select-objects target-args)
-          (let ((caching (getf qualifier-args :caching t))
+          (let ((caching (getf qualifier-args :caching *default-caching*))
                 (result-types (getf qualifier-args :result-types :auto))
                 (refresh (getf qualifier-args :refresh nil))
                 (database (or (getf qualifier-args :database) *default-database*))
@@ -1136,7 +1149,8 @@ as elements of a list."
   (unless (record-caches database)
     (setf (record-caches database)
          (make-hash-table :test 'equal
-                          #+allegro :values #+allegro :weak
+                          #+allegro   :values    #+allegro :weak
+                          #+clisp     :weak      #+clisp :value
                            #+lispworks :weak-kind #+lispworks :value)))
   (setf (gethash (compute-records-cache-key targets qualifiers)
                 (record-caches database)) results)