[Openmcl-devel] Invalid view-database type

Osei Poku osei.poku at gmail.com
Tue Mar 10 13:55:35 PDT 2009


On Mar 10, 2009, at 1:37 AM, Osei Poku wrote:

> Hello,
>
> It seems upon upgrading to CCL 1.3, I am now getting this error.    
> Inspecting the slot definition of VIEW-DATABASE of the STANDARD-DB- 
> OBJECT confirms that the expected type of that slot is infact NIL.   
> Any ideas?
>
> The value #<MYSQL-DATABASE localhost/twdb_lsi_design1_block1/opoku  
> OPEN #x300051D6604D>, derived from the initarg :VIEW-DATABASE, can  
> not be used to set the value of the slot CLSQL-SYS::VIEW-DATABASE in  
> #<FAILDATA-TABLE #x300052859B1D>, because it is not of type NIL.
>   [Condition of type CCL::BAD-SLOT-TYPE-FROM-INITARG]
>
> Thanks,
>
> Osei


Upon further investigation and help from Gary Byers (CCL guru/ 
developer/all-round-amazing programmer), I have figured out the source  
of this error.  The slot type was defaulting to NIL in COMPUTE-LISP- 
TYPE-FROM-SPECIFIED-TYPE.  This worked in CCL pre-1.3 because a NIL  
type was assumed to mean just mean T was supposed to be there since a  
NIL type does not really make sense.  However, CCL 1.3 does not like  
NIL type specifiers for slots and gives the above INVALID TYPE error  
when attempting to set the value of any STANDARD-DB-CLASS slot whose  
type is not explicitly specified.  This is Gary's explanation...

>
> I think that 1.2 and earlier may have treated "... :type nil ..."
> in a slot specification as if the :type option was missing (and
> therefore defaulted to T.)  That isn't correct, though it did
> mask the fact that saying that a slot has a type of NIL is almost
> certainly incorrect (even if it's well-defined.)
>
> Really saying that a slot has type NIL is obscure enough that
> I wouldn't be too upset if DEFCLASS warned about it.
>
> I would guess that that the author(s) of CLSQL didn't really
> intend to say that the slot in question had type NIL ...
>


This is the old code that computes the slot definition for a VIEW- 
CLASS.  As you can see, the TYPE variable defaults to NIL in the DO*  
initializer.  Changing this to default to T fixed my problem.  I have  
inlined a diff to the latest git repository with this fix.

(defmethod initialize-instance :around ((obj view-class-direct-slot- 
definition)
                                         &rest initargs)
   (do* ((parsed (list obj))
         (name (first initargs) (first initargs))
         (val (second initargs) (second initargs))
         (type nil)
         (db-constraints nil))
       ((null initargs)
        (setq parsed
              (append parsed
                      (list 'specified-type type
                            :type (compute-lisp-type-from-specified-type
                                   type db-constraints))))
        (apply #'call-next-method parsed))
     (case name
       (:db-constraints
        (setq db-constraints val)
        (setq parsed (append parsed (list name val))))
       (:type
        (setq type val))
       (t
        (setq parsed (append parsed (list name val)))))
     (setq initargs (cddr initargs))))

---- begin patch ----

diff --git a/sql/metaclasses.lisp b/sql/metaclasses.lisp
index 2a0b4b9..54475aa 100644
--- a/sql/metaclasses.lisp
+++ b/sql/metaclasses.lisp
@@ -432,7 +432,7 @@ implementations."
    (do* ((parsed (list obj))
          (name (first initargs) (first initargs))
          (val (second initargs) (second initargs))
-        (type nil)
+        (type t)
          (db-constraints nil))
        ((null initargs)
         (setq parsed

---- end patch ----



More information about the Openmcl-devel mailing list