I was fiddling with
CLSQL again and came across some minor inconveniences and one major one. To the minor inconveniences: there is no sane way to handle constraints with the OODDL, i.e.
def-view-class. For instance, how do you specify a foreign-key? Yes, of course, there is
:db-type :join but that is for something else. And
:db-constraints just takes a rather small set of keywords like
:unique. Seems like the only way to go is to call
CREATE TABLE which accepts a string argument (for direct SQL commands) to
:constraints. Next, what happens if your view-class wants to use a sequence? Sure, you can create a sequence just fine and also use it flawlessly with an existing table. But there is no
:type serial argument, you have to go and specify a direct SQL statement with
:db-type serial.
Now, the major complaint I have, though, is a different one.
create-view-from-class is a misnomer. It doesn't create views at all. In fact, there is no way to create a DB-view from a CLSQL-view. Perhaps, this isn't to surprising after all, as for a view you have to specify a SQL select statement which can get rather complex, like SQL joins even, right? But wait, there is
:db-type :join which actually just does that. Given the power of
:db-type :join, I don't really understand what the problem is behind the lack of a real
create-view-from-class. Ultimately, I believe this might also be a compatibility issue (I don't know, though). Perhaps the developers fear that no user of CLSQL would update from
create-view-from-class to
create-table-from-class or some such. Or they believe that no one will ever be setting up their DB from within Lisp.