Re: [sqlalchemy] Union on relationship

2016-10-27 Thread mike bayer
On 10/26/2016 10:40 PM, Alfred Soeng wrote: Hi Mike, Are you free to talk through the fb messenger about my issue if you are good to it? Hi Alfred - unfortunately my time is limited to being able to answer isolated questions on this list. However, there are a handful of people you can

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread Alfred Soeng
Hi Mike, Are you free to talk through the fb messenger about my issue if you are good to it? Best, Alfred On Tue, Oct 25, 2016 at 2:44 PM, mike bayer wrote: > In a case like this I don't know what the problem is without being able to > run an example. The

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread mike bayer
On 10/26/2016 02:09 PM, Alfred Soeng wrote: First of all, thanks for your response. 1. That makes more sense. 2. I use a select first, because there are actually more than 2 types of circuits, so there should be more models to be mapped to T_circirt. There are some models don't have vendor

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread Alfred Soeng
First of all, thanks for your response. 1. That makes more sense. 2. I use a select first, because there are actually more than 2 types of circuits, so there should be more models to be mapped to T_circirt. There are some models don't have vendor but need to be mapped to the consistent model

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread mike bayer
On 10/26/2016 12:03 PM, Alfred Soeng wrote: q1 = session.query(c1.mapper._class).options(joinedload('vendor')).options(load_load('id')) q2 = session.query(c2.mapper._class).options(joinedload('vendor')).options(load_load('id')) q1.union(q2).all() So there's some things to happen here: 1.

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread Alfred Soeng
struct T_AssetTransitCircuit { 1. asset_id 2. vendor_id 3. vendor } struct T_AssetTransportCircuit { 1. asset_id 2. vendor_id 3. vendor } struct T_Vendor { 1: i32 id, 2: optional string name, 3: optional string sf_id, 4: optional string transit_as_id, 5: optional i64 created_by, 6:

Re: [sqlalchemy] Union on relationship

2016-10-26 Thread mike bayer
In a case like this I don't know what the problem is without being able to run an example. The guidelines at http://stackoverflow.com/help/mcve would make this easiest. Can we see complete mappings / table information (only what's needed to reproduce the problem) as well as how you are

[sqlalchemy] Union on relationship

2016-10-25 Thread Alfred Soeng
When I union 2 queries, it seems combine the same relationship together and cause the alias problem In the code, it generated 2 queries like: q1: SELECT anon_1.id AS anon_1_id, anon_1.vendor_id AS anon_1_vendor_id, vendor_1.id AS vendor_1_id, vendor_1.name AS vendor_1_name, vendor_1.sf_id AS