Hello,

qry =
session.query(AssetCategory).join(Asset).join(Shot).filter(Shot.id==1).distinct()

this one already did the trick.

qry = qry.filter(Shot.id==shot_id_of_interest)


what did you add this for? The results seem to be identical...


that generates
SELECT DISTINCT "AssetCategory".id AS "AssetCategory_id"
FROM "AssetCategory" JOIN "Asset" ON "AssetCategory".id =
"Asset".category_id JOIN "Shot" ON "Shot".id = "Asset".shot_id
WHERE "Shot".id = :id_1


Here it generates:
SELECT DISTINCT "AssetCategory".id AS "AssetCategory_id", "AssetCategory".name AS "AssetCategory_name"
FROM "AssetCategory" JOIN "Asset" ON "AssetCategory".id =
"Asset".category_id JOIN "Shot" ON "Shot".id = "Asset".shot_id
WHERE "Shot".id = :id_1


This leads to my next question: where does sqlalchemy know from on which column to use the distinct expression (apart from using the primary key?). I am using sqlalchemy 0.5.8, perhaps there is a difference?!

Thanks

Sebastian

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to