Re: join keys redux

Cyrus Harmon <ch-clsql-dl6SmSK5uza1Z/[email protected]>
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
Ok, so Kevin's sort of right, at least. The functionality I'm looking 
for is supported in CLSQL. BUT, it's broken in 
clsql:update-object-joins. When I do the following:

(deftest :ooddl/join/1
  (clsql:update-objects-joins (list company1))
  (mapcar #'(lambda (e)
	     (print (slot-value e 'first-name))
	     (slot-value e 'ecompanyid))
   (company-employees company1))
  (1 1 1 1 1 1 1 1 1 1))

I get this error message:

#<CLSQL-TESTS::COMPANY #x65FB5F6> has no slot named 
(CLSQL-TESTS::COMPANYID
                                                      
CLSQL-TESTS::GROUPID).
    [Condition of type SIMPLE-ERROR]

But, the test works if I take out the update-objects-join line. So, the 
functionality is supported, but there are some areas on the edges where 
it needs to be fixed. This is good news and means that it should be 
pretty straightforward to fix update-objects-joins, I imagine. I'll 
take a look and see what I can find.

As for the point about the dog owners, yeah, I can see the merits of 
doing it as you describe, but one of the nice things about the OODDL is 
that it has the potential to hide most selects and do them under the 
covers. I think this is a good thing. You can argue that the overhead 
of the new class doesn't warrant this, but I'd argue that the ability 
to hide this stuff behind the CLSQL MOP allows one to do some really 
cool meta-data based stuff with automatic joining and updating. I'd 
just as soon see as much of the logic pushed down into the 
def-view-class and be able to leave out the kind of select Kevin 
proposes, which is admittedly a decent workaround.

Thanks,

Cyrus

On Jan 25, 2005, at 3:13 AM, Kevin Rosenberg wrote:

> Cyrus Harmon wrote:
>> 1. CLSQL def-view-class bug - we should fix the def-view-class stuff 
>> to
>> allow for specifying lists for home-key and foreign key.
>
> I look a look at tests/test-init.lisp. I do have a test view class
> containing the following:
>
>   (employees
>     :reader company-employees
>     :db-kind :join
>     :db-info (:join-class employee
>                           :home-key (companyid groupid)
>                           :foreign-key (ecompanyid groupid)
>                           :set t))))
>
> You might want to look at the tests in the test suite that use that
> view class.
>
> Yes, I could see how you might have a view class such as DOG-OWNERS
> and then you could just say
>   (select 'DOG-OWNERS)
>
> But, isn't the much more common idiom something like
>
> (select-animal-type-owners 'dog)
>
> (defun select-animal-type-owners (a-type)
>   (select 'pet-owner-person :where [= [animal_type] a-type]))
>
> This way you don't need to create a new view class every time you want
> to select for a different animal type.
>
> Kevin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.