bjoin = {} for t in 'BCE': try: bjoin[t] = ajoin[t] except KeyError: pass Bjoin = polymorphic_union(bjoin, None) class mappers: pass mappers.A = _printcallfunc(mapper, A, tables.A, select_table=Ajoin, polymorphic_on=Ajoin.c.atype, polymorphic_identity='A') mappers.A1 = _printcallfunc( mapper, A, ajoin['A'].alias('abz'), #tables.A, select_table=ajoin['A'].alias('abz'), - does not work non_primary=True, polymorphic_identity='A') if db.USE_B: mappers.B = _printcallfunc(mapper, B, tables.B, select_table=Bjoin,
Column('name', Text), Column('B_data', Text), Column('man2', Text), ) ECHO=10 db = DB( ECHO) DB.USE_E = DB.USE_D = 0 class mappers: pass mappers.A= _printcallfunc( mapper, A, tables.A, polymorphic_on=tables.A.c.atype, polymorphic_identity='A') mappers.A1= mapper( A, tables.A.select( tables.A.c.atype=='A').alias('abz'), non_primary=True, ) mappers.B= _printcallfunc( mapper, B, None, inherits=mappers.A, polymorphic_identity='B') mappers.B1= _printcallfunc( mapper, B, tables.A.select( tables.A.c.atype=='B').alias('bbz'), non_primary=True, ) mappers.C= mapper( C, None,
) ECHO = 10 db = DB(ECHO) DB.USE_E = DB.USE_D = 0 class mappers: pass mappers.A = _printcallfunc(mapper, A, tables.A, polymorphic_on=tables.A.c.atype, polymorphic_identity='A') mappers.A1 = mapper( A, tables.A.select(tables.A.c.atype == 'A').alias('abz'), non_primary=True, ) mappers.B = _printcallfunc(mapper, B, None, inherits=mappers.A, polymorphic_identity='B')
te = join( tables.B, tables.E, tables.B.c.i_d == tables.E.c.i_d) #explicit tbx=join( tables.A, tb, tables.A.c.i_d == tb.left.c.i_d ) Ajoin = polymorphic_union( ajoin.copy(), None) if db.USE_B: bjoin = {} for t in 'BCE': try: bjoin[t] = ajoin[t] except KeyError: pass Bjoin = polymorphic_union( bjoin, None) class mappers: pass mappers.A= _printcallfunc( mapper, A, tables.A, select_table=Ajoin, polymorphic_on=Ajoin.c.atype, polymorphic_identity='A') mappers.A1= _printcallfunc( mapper, A, ajoin['A'].alias('abz'), #tables.A, select_table=ajoin['A'].alias('abz'), - does not work non_primary=True, polymorphic_identity='A') if db.USE_B: mappers.B= _printcallfunc( mapper, B, tables.B, select_table= Bjoin, polymorphic_on= Bjoin.c.atype, inherits=mappers.A, polymorphic_identity='B') mappers.B1= mapper( B, bjoin['B'].alias('bbz'), #tables.B.select( tables.B.c.atype == 'B').alias('tbs'), #tables.B, select_table= # inherits=mappers.A1, XXX breaks non_primary=True,
if db.USE_D: ajoin['D'] = tables.D.select(**corr) if db.USE_E: ajoin['E'] = tables.E.select(**corr) Ajoin = polymorphic_union( ajoin,'atype', ) print Ajoin if db.USE_B: bjoin = {} for t in 'BCE': try: bjoin[t] = ajoin[t] except KeyError: pass Bjoin = polymorphic_union( bjoin,'atype', ) class mappers: pass mappers.A= _printcallfunc( mapper, A, tables.A, select_table=Ajoin, polymorphic_on=Ajoin.c.atype, concrete=True, polymorphic_identity='A') mappers.A1= mapper( A, tables.A, non_primary=True, concrete=True, polymorphic_identity='A') if db.USE_B: mappers.B= _printcallfunc( mapper, B, tables.B, select_table=Bjoin, polymorphic_on=Bjoin.c.atype, inherits=mappers.A, concrete=True, polymorphic_identity='B') mappers.B1= mapper( B, tables.B, #inherits=mappers.A1, non_primary=True, concrete=True, polymorphic_identity='B')