Re: Bug: update-instance-from-records

Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> Sun, 19 Mar 2006 09:01:22 -0700
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
Joel Reymont wrote:
> If I select a record the OO way then my slot values are converted  
> from strings and the instance is associated with a database. If I  
> make-instance, set the key slots and try update-instance-from-records  
> then several things happen:

Creating an CLSQL object with make-instance has not supported. It
appears that you need something more than the CommonSQL API is
providing. Is there a reason that you're not creating your objects
with SELECT rather than trying to generate a key yourself and trying
to call UPDATE-INSTANCE-FROM-RECORDS?

> 1) I get an error from update-slot-from-db. The very first cond  
> clause uses (view-database instance) but that is nil. database- 
> underlying-type then complains.

That's right. If using U-I-F-R, that means the instance already should
have an associated database.
 
> 2) If I change the update-slot-from-db code to use (or (view-database  
> instance) *default-database*) then my record is updated but the slot  
> values are not converted according to types specified in def-view- 
> class. All slots retrieved by update-instance-from-records are set to  
> string values.

As above, if you're going to try to work around CLSQL's default object
creation, you should store the database in the object before calling
U-I-F-R.

As for the slot conversions, I'd have to reread the source code to see
where to conversions are happening to see why your use of U-I-F-R is
not invoking them.

> I'm currently resorting to the following but there must be an easier  
> way:

Taking a quick look at your code, yes, I think it's likely a simple
way exists.

-- 
Kevin Rosenberg
[email protected]