On 4/9/15 1:50 PM, Jacob Magnusson wrote:

I have this case with a bundle that looks something like this:

|primate_bundle = Bundle( 'primate', Primate.name, Bundle('wooden_tool', *[ WoodenTool.id, WoodenTool.name, WoodenToolCategory.name.label('category'), ]), Bundle('solid_tool', *[ SolidTool.id, SolidTool.name, SolidToolCategory.name.label('category'), ]) ) |

Then I query it like this:

|session.query(primate_bundle) .select_from(Primate) .join(WoodenTool, Primate.main_tool) .join(WoodenToolCategory, WoodenTool.category_id == WoodenToolCategory.id) .join(SolidTool, Primate.secondary_tool) .join(SolidToolCategory, SolidTool.category_id == SolidToolCategory.id) .all() |

However, since the label for category name is the same within both sub-bundles it will throw |Ambiguous column name| (because the compiled SQL labels will be exactly the same). Adding |.with_labels()| doesn’t fix it. Full traceback can be seen by running the included examples. Commenting out one of the |.label()| lines in the example makes it runnable. Do you guys have a clean solution to support this use case? I really like this feature of creating your own custom made results so it would be a shame to not be able to do this.

Yeah, OK I see why that is, I'll try to take a look at this later today. The Bundle thing is obviously new and you're the first person I'm seeing actually use it. You might need to work around for now :/





Tested on SQLAlchemy 1.0.0b5 and 0.9.9. Python 3.

Thank you so much for any potential help you can give me on this. I’ve followed the source code for |Bundle| but I can’t think of a clean way to this…

​
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to