From: Vsevolod (S. I. <si...@cs...> - 2004-01-05 12:07:04
|
Chris, >> 1. Why do you lowercase field names? Can this be a configuration >> option instead? > > > Where is this giving you a problem? I probably did this to ensure that > everything was handled consistently internally. It happens once in SPOPS::Tool::DBI::DiscoverField and a whopping eight times :) in SPOPS::Tie. > I'm not exactly sure what you mean, but you can specify join clauses in > the fetch_group: > > my $people = Person->fetch_group({ > where => "address.city = ? AND person.address_id = address.address_id, > from => [ 'address', 'person' ], > value => [ 'Pittsburgh' ], > }); > > I'll make a change so you don't need to add 'person' (the table of the > class we're querying) to the 'from' list. (That's kind of annoying...) > You can also pass where clauses to the generated links_to method. The > attached script is an example (standalone, uses SQLite). The script is cool (I did not know you could do that :), but my problem is similar to your Pittsburgh example. My code looks similar. But if the definition of Person has_a Address, it feels redundant to specify the "person.address_id = address.address_id" clause. (And the clauses for links_to classes are even bulkier.) I wish I could just automagically say my $people = Person->fetch_group({ where => "city = 'Pittsburg'}); Of course, if more than one dependent class of Person has the 'city' field, there has to be a way of choosing the one we need. Perhaps it can be prefixed: "address.city='Pittsburg'", where "address" is not the name of the table with addresses, but the alias of the address_id field in Person. Then the table structure is nicely abstracted away. :) > Beyond that... the whole links_to/fetch_by stuff has been kind of > stagnant for quite some time. It needs to be revisited and perhaps > rethought a bit... I saw the note by Ray Zimmerman mentioned in your documentation and already ran into some of its issues with the order of saving of the contained classes (for a new object, the has_to classes have to be saved first, then their ids should be given to the top-level object, then this object should be saved, then its id should be used to save the links_to objects). After I get a bit more familiar with SPOPS, let me know if I can give you a hand with this. Simon -- Simon (Vsevolod ILyushchenko) si...@cs... http://www.simonf.com America's business leaders simply don't want to think about complex technology issues - they want to think about golf. Microsoft promises them that. Andrew Grygus, www.aaxnet.com |