Lisp HUG Maillist Archive

Common SQL

Here we go. Assume I have this classes.. (not really tested but just
to get some code.


(def-view-class foo ()
        ((foo-id 
        :db-kind :key
        :type integer)
        (bar
           :accessor foo-bar
           :db-kind :join
           :db-info (:join-class bar
                     :home-key foo-id
                     :foreign-key bar-id
                     :set nil)))
        (:base-table foo))
                      
(def-view-class bar ()
         ((bar-id 
           :db-kind :key
           :type integer)
        (foo 
           :accessor bar-foo
           :db-kind :join
           :db-info (:join-class foo
                     :home-key bar-id
                     :foreign-key foo-id
                     :set nil)))
        (:base-table bar))

        
How do I build a connecton from foo to bar and back and how to break
it cleanly? 

CommonSQL maps all to UPPERCASE so if I have a bar here it will get
mapped to a table BAR. How can I change that to force it kept
downcase? I do not want to write |bar|, which obviously does work.

Now to my critique. The quality of the Documentation is IMHO
especially about CommonSQL very bad. The only example I found was just
the class declaration in the Reference Manual but no-where did I find
and example on how to use that classes. I would think that improving
the documentation should move up on the priority list from Xanalys. At
least I would expect that Document strings are used. It's really
nerving to have to figure out how things working but just looking at
their name.

Regards
Friedrich


Common SQL

>>>>> Friedrich Dominicus writes:
        
Friedrich> How do I build a connecton from foo to bar and back and how to break
Friedrich> it cleanly? 

I don't understand this question.  Do you mean how to create a bar
such that accessing the join slot it foo will retrieve bar?


Friedrich> CommonSQL maps all to UPPERCASE so if I have a bar here it will get
Friedrich> mapped to a table BAR. How can I change that to force it kept
Friedrich> downcase? I do not want to write |bar|, which obviously does work.

Since it "obviously does work", why in the world do you not want to
use it?  If you're trying to avoid interning the symbol, just
use (:base-table #:|bar|).

Friedrich> Now to my critique. The quality of the Documentation is IMHO
Friedrich> especially about CommonSQL very bad. 

I agree (though I would probably have phrased it somewhat more
diplomatically :-).  Many supported options are not even
documented at all.

I have a file implementing a fairly exhaustive test suite
showing most (all?) the supported options of Common SQL.
Would anyone be interested in that?  [I'd have to clear
all the legalities with Memetrics and Xanalys first, of course.]


--
			Alain Picard
			Memetrics


Re: Common SQL

Alain Picard <Alain.Picard@memetrics.com> writes:

> >>>>> Friedrich Dominicus writes:
>         
> Friedrich> How do I build a connecton from foo to bar and back and how to break
> Friedrich> it cleanly? 
> 
> I don't understand this question.  Do you mean how to create a bar
> such that accessing the join slot it foo will retrieve bar?
Well the classes do have a connection through their different keys but
the only way I can see at the moment to relat them is by explicitly
setting the slots of both to the appropriate values. 

so in the example I've to do
create the objects 
than set the bar and foo slots from either foo or bar. And better do
not forget the keys. 




> 
> 
> Friedrich> CommonSQL maps all to UPPERCASE so if I have a bar here it will get
> Friedrich> mapped to a table BAR. How can I change that to force it kept
> Friedrich> downcase? I do not want to write |bar|, which obviously does work.
> 
> Since it "obviously does work", why in the world do you not want to
> use it?  If you're trying to avoid interning the symbol, just
> use (:base-table #:|bar|).
Well it should be possible IMHO to have an optio to that the used case
too e.g SQL:*MAP-CASE* :downcase or the like and from there on 'foo ->
mapped to foo not FOO 
> 
> Friedrich> Now to my critique. The quality of the Documentation is IMHO
> Friedrich> especially about CommonSQL very bad. 
> 
> I agree (though I would probably have phrased it somewhat more
> diplomatically :-).  
What phrases would you have preferred? I don't think that I was to
harsh I just stated clearly that the documentation is not good. 

>Many supported options are not even
> documented at all.
> 
> I have a file implementing a fairly exhaustive test suite
> showing most (all?) the supported options of Common SQL.
> Would anyone be interested in that? 
Well I would be interested of course. 

Regards
Friedrich


Re: Common SQL

In uncommon sql there is a function called add-to-relation() that may
be what you are looking for.  Essentially, something like:

(let ((f (make-instance 'foo))
      (b (make-instance 'bar)))
  (add-to-relation f 'foo-bar b)
  (add-to-relation b 'bar-foo f))

-sdk


> Here we go. Assume I have this classes.. (not really tested but just
> to get some code.
> 
> 
> (def-view-class foo ()
>         ((foo-id 
>         :db-kind :key
>         :type integer)
>         (bar
>            :accessor foo-bar
>            :db-kind :join
>            :db-info (:join-class bar
>                      :home-key foo-id
>                      :foreign-key bar-id
>                      :set nil)))
>         (:base-table foo))
>                       
> (def-view-class bar ()
>          ((bar-id 
>            :db-kind :key
>            :type integer)
>         (foo 
>            :accessor bar-foo
>            :db-kind :join
>            :db-info (:join-class foo
>                      :home-key bar-id
>                      :foreign-key foo-id
>                      :set nil)))
>         (:base-table bar))
> 
>         
> How do I build a connecton from foo to bar and back and how to break
> it cleanly? 
> 
> CommonSQL maps all to UPPERCASE so if I have a bar here it will get
> mapped to a table BAR. How can I change that to force it kept
> downcase? I do not want to write |bar|, which obviously does work.
> 
> Now to my critique. The quality of the Documentation is IMHO
> especially about CommonSQL very bad. The only example I found was just
> the class declaration in the Reference Manual but no-where did I find
> and example on how to use that classes. I would think that improving
> the documentation should move up on the priority list from Xanalys. At
> least I would expect that Document strings are used. It's really
> nerving to have to figure out how things working but just looking at
> their name.
> 
> Regards
> Friedrich


Re: Common SQL

>>>>> Friedrich Dominicus writes:

Friedrich> "Scott D. Kalter" <mithril@brandx.net> writes:
>> In uncommon sql there is a function called add-to-relation() that may
>> be what you are looking for.  Essentially, something like:
>> 
>> (let ((f (make-instance 'foo))
>> (b (make-instance 'bar)))
>> (add-to-relation f 'foo-bar b)
>> (add-to-relation b 'bar-foo f))
Friedrich> Well I know that, but such a thing does not exist in
Friedrich> CommonSQL. Therfor my question how I'm supposed to do that with
Friedrich> CommonSQL.
Friedrich> Regards
Friedrich> Friedrich

FWIW, the way we solved this is by writing a hairy macro
called DEFINE-PERSISTENT-CLASS which defines concepts of
"ownership" between objects, so that one can, for instance, 
say

(make-instance* owner 'owned-class :arg1 par1 ...)

and

(delete-from owner ownee)

etc.  Thus, I'd say that def-view-class is a nice toolkit, but
is not a "solution"; you need a lot of extra "intelligence"
(sometimes domain specific) built on it to get a "solutions".

How are other users of CommonSQL faring?

--
			Alain Picard
			Memetrics


Updated at: 2020-12-10 09:01 UTC