Hello,
DEFTABLE seems fine (or "almost" fine, I'll have to actually try it) for before/after code as I need it, but the constraints inside DAOs seem to be what I actually need.
Here's what I'm trying to achieve: separate single-component library with basic functionality (for e.g. Wordpress-like taxonomy applicable to any "item" in any "site", or for user accounts with registration, activation, password recovery and such); data model entities represented by DAOs; DAO-level inheritance to support project-specific functionality (e.g. user-profile columns, specific foreign keys for taxonomy, and so on). With constraints supported by DAOs it's possible to actually inherit the real schema, and DEFTABLE doesn't support inheritance -- it seems it would be hard to add, and it wouldn't fit well there. Putting constraints in DEFTABLE would break on DAO inheritance, and putting them in DAOs makes it possible not to tinker with hand-written SQL and fitting it to DAOs for every specific use case.
However, the more I think about before/after SQL forms, the more it seems they don't actually belong to DAOs and using DEFTABLE or custom init functions will be a better way. BTW, thanks for pointing out the DEFTABLE -- it named a completely different feature before (or there was a similar name), and I didn't notice it's a new one.
Regards, Maciej
On 2008-10-11, at 12:24, Marijn Haverbeke wrote:
Hey Maciej,
I have no time to look into this right away -- but did you see the deftable stuff? The idea is that you combine all the stuff needed to define a table or view in a deftable form. I intentionally didn't include complicated functionality in the DAO syntax, since they are just access objects, not definitions, and trying to support everything there is an endless labour. Constraints can be added after a table has been defined, which is how I usually do it (if I remember correctly theres already a !foreign operator, and similar ones can be defined for other useful constraints).
Cheers, Marijn
2008/10/11 Maciej Pasternacki maciej@pasternacki.net:
Hello,
Since it's not my first patch for Postmodern, and most probably not the last one, I can as well subscribe to the list and send patches properly instead of in a private e-mail.
I just made a small update to DAOs to use constraints (foreign keys, checks, indices) for DAO slots and classes. Doesn't seem to break anything, and makes it possible (or almost possible) to drop separate .sql definition files and just use DAO-TABLE-DEFINITION.
What's missing for me is arbitrary SQL for e.g. defining needed functions, enum types and so on before creating table -- but I'm not sure what approach should I take: move it all to DAOs (as e.g. :BEFORE-CREATE-TABLE and :AFTER-CREATE-TABLE class slots), or just make init function for my package, which would call needed queries and use DAO-TABLE-DEFINITION just to create the tables. Would there be any advantage to :BEFORE-... and :AFTER-... slots, or is the init function the preferred way to go?
Regards, Maciej.
-- -><- Maciej Pasternacki -><- http://www.pasternacki.net/ -><-
postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
postmodern-devel mailing list postmodern-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel