before even running it I added this:

print class_mapper(Submission).props['people'].primaryjoin
print class_mapper(Submission).props['people'].secondaryjoin
print class_mapper(Submission).props['people'].lazywhere
print class_mapper(Person).props['submissions'].lazywhere

which revealed the issue:

submission.id = person_submission_map.submission_id
person.id = person_submission_map.person_id
? = person_submission_map.submission_id AND person.id =  
person_submission_map.person_id
person.id = person_submission_map.person_id AND submission.id =  
person_submission_map.submission_id

which is, the last line there is the "lazy" clause when loading  
"submissions", but it has no place to set the ID of the parent object  
(you can see the lazy clause above it, corresponding to 'people',  
does).  so I made a small enhancement to the "lazy determination"  
step to be smarter about matching columns to tables in rev 1770 which  
fixes this issue.

On Aug 7, 2006, at 10:24 PM, Jamie Wilkinson wrote:

> Hey,
>
> I've got some interesting behaviour on a slightly obtuse schema:  I  
> map a
> Person onto two tables, 'account' and 'person', which store login  
> details
> and personal details, respectively.  I then have a many-many join  
> onto a
> submission table, which contains details about papers.
>
> Attached is a the simplified version, which has 4 tables, and two  
> mappers on
> two domain objects.
>
> The assertion that fails shows that the query returning the list of
> submissions assigned to the third person is incorrect.  You get the  
> correct
> behaviour if you change the Person mapper to not join on account  
> and person,
> getting a query that looks like:
>
> SELECT submission.title AS submission_title, submission.id AS  
> submission_id
> FROM person_submission_map, submission
> WHERE ? = person_submission_map.person_id AND submission.id =  
> person_submission_map.submission_id ORDER BY person_submission_map.oid
>
> which is doing the right thing, asking for a person_id.
>
> The failing query looks like:
>
> SELECT submission.title AS submission_title, submission.id AS  
> submission_id
> FROM person, person_submission_map, submission
> WHERE person.id = person_submission_map.person_id AND submission.id  
> = person_submission_map.submission_id ORDER BY  
> person_submission_map.oid
>
> which isn't looking for a specific person when it runs the query,  
> and hence
> returns an invalid set of data.
>
> So, am I doing something wrong?  Does the Person mapper need extra
> information to perform many-many joins?  Or is this a bug? :)
>
> If it's a bug, ideas for workaround would be welcome too.
> <sa-many-many-join.py>
> ---------------------------------------------------------------------- 
> ---
> Using Tomcat but need to do more? Need to support web services,  
> security?
> Get stuff done quickly with pre-integrated technology to make your  
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
> Geronimo
> http://sel.as-us.falkag.net/sel? 
> cmd=lnk&kid=120709&bid=263057&dat=121642______________________________ 
> _________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to