johnf wrote: > In a many to many relationship there is often a third table -intermediary > table. Normally, I link based on two fields. But bizobj.LinkField only > allows one string or one field. It would be nice if the bizobj.LinkField > could accept a tuple with multi fields and have the where cause work > correctly for the child. > > So it would be nice to have a bizobj.LinkField that accepted more than just > one field. > > Of course there maybe a different way to handle the situation of needing a > where clause that requires to fields.
What I do is define a base bizobj for the intermediary table, and then make 2 subclasses, one for each parent. For example, with a people table and a categories table, where each person can be a member of any number of categories: create table people (id integer primary key, name char); create table categories (id integer primary key, name char); create table peoplecat (id integer primary key, person_id, category_id); The peoplecat table is the intermediary table. So I make a bizobj on the peoplecat table, with SQL like: select peoplecat.id as id, peoplecat.person_id as person_id, peoplecat.category_id as category_id, people.name as person_name, categories.name as category_name left join people on people.id = peoplecat.person_id left join categories on categories.id = peoplecat.category_id group by peoplecat.id I then make 2 subclasses, PeopleForCategory and CategoriesForPerson. PeopleForCategory has a LinkField of category_id, and CategoriesForPerson has a LinkField of person_id. Your People bizobj adds CategoriesForPerson as a child, and your Categories bizobj adds PeopleForCategory as a child. Your UI then uses a grid to display the child records, and you write code to add more categories/people links, or to delete existing links. That code should mostly go in the base bizobj class for the intermediary bizobj. I find this works very well. Not sure if we can really put something in the framework to handle this automatically... Paul _______________________________________________ Post Messages to: Dabo-users@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/4a0c46f8.1070...@ulmcnett.com