From: Randall S. <ra...@tn...> - 2006-01-05 22:58:09
|
While it is on my mind, what would a good syntax be for this. I initially thought. A.select(C) A.select(C.q.name == 'dog') Currently, that does a Cross Join. I've never seen a need to use a Cross Join, but I sure don't want to change this functionality. Another idea. Use a keyword. # These only work if a multiple join is already defined. A.select(multiple_join=(C.q.name == 'dog', )) A.select(multiple_join=(B.q.status == 'A', C.q.name == 'dog')) Z.select(multiple_join=(B.q.status == 'A', )) #For a concrete useful example, let's talk about drinking water because #I work in drinking water regulation. Entitys: WaterSystem -> Facility -> SamplePoint -> Sample -> Results # Each relationship is a MultipleJoin. # All SamplePoints for a WaterSystem sample_points = SamplePoint.select(multiple_join=WaterSystem) #Say I want a list of cyanide sample results for active SamplePoints #for WaterSystem 0200001 with a level > .02 mg/l after 2005-01-01. results = Results.select(multiple_join=(AND( WaterSystem.q.st_id == '0200001', SamplePoint.status == 'A', Sample.date_coll > datetime.datetime(2005, 1, 1), Results.anl_code = '1024', Results.result > 0.2)) This may be some errors in there, but maybe you get the point. The point is that I've already told SQLObject how objects are related when I defined the classes, so I shouldn't need to do it again. It should be able to figure out how these things are related. Randall |