Hi Ezio,

I have the following code:

--------------------8<--------------------
duplicata_table = Table('DUPLICATA', metadata,
   Column('dpl_loja', String(2), primary_key=True),
   Column('dpl_id', Integer, Sequence('GEN_DPL_ID'), primary_key=True),
   Column('dpl_ticket', Integer),
   Column('dpl_documento', String(30)),
   Column('dpl_cnpj_cpf', String(14)),
   Column('dpl_razao_social', String(50)),
   Column('dpl_valor_total', Numeric),
   Column('dpl_valor_total_pago', Numeric),
   Column('dpl_data_emissao', Date)
   )

duplicata_parcela_table = Table('DUPLICATA_PARCELA', metadata,
   Column('dpl_loja', String(2), primary_key=True),
   Column('dpl_id', Integer, primary_key=True),
   Column('dplpar_parcela', String(2), primary_key=True),
   Column('dplpar_tipo', String(1)),
   Column('dplpar_tipo_pagto', String(1)),
   Column('dplpar_data_vencto', Date),
   Column('dplpar_data_vencto_orig', Date),
   Column('dplpar_valor', Numeric),
   Column('dplpar_valor_pago', Numeric),
   Column('dplpar_perc_juros', Numeric),
   Column('dplpar_valor_juros', Numeric),
   ForeignKeyConstraint(['dpl_loja', 'dpl_id'], ['DUPLICATA.dpl_loja',
'DUPLICATA.dpl_id']),
   )

mapper(Duplicata, duplicata_table, properties={
   'loja': duplicata_table.c.dpl_loja,
   'id': duplicata_table.c.dpl_id,
   'ticket': duplicata_table.c.dpl_ticket,
   'documento': duplicata_table.c.dpl_documento,
   'cnpj_cpf': duplicata_table.c.dpl_cnpj_cpf,
   'razao_social': duplicata_table.c.dpl_razao_social,
   'valor_total': duplicata_table.c.dpl_valor_total,
   'valor_total_pago': duplicata_table.c.dpl_valor_total_pago,
   'data_emissao': duplicata_table.c.dpl_data_emissao
   })

mapper(DuplicataParcela, duplicata_parcela_table, properties={
   'loja': duplicata_parcela_table.c.dpl_loja,
   'id': duplicata_parcela_table.c.dpl_id,
   'parcela': duplicata_parcela_table.c.dplpar_parcela,
   'tipo': duplicata_parcela_table.c.dplpar_tipo,
   'tipo_pagamento': duplicata_parcela_table.c.dplpar_tipo_pagto,
   'data_vencimento': duplicata_parcela_table.c.dplpar_data_vencto,
   'data_vencimento_original':
duplicata_parcela_table.c.dplpar_data_vencto_orig,
   'valor': duplicata_parcela_table.c.dplpar_valor,
   'valor_pago': duplicata_parcela_table.c.dplpar_valor_pago,
   'duplicata': relation(Duplicata, backref='parcelas', lazy=False)
   })
--------------------8<--------------------


As you can see, I am using eager loading...

When I try to select all DuplicataItem, SA generates this SQL:

SELECT
 "DUPLICATA_PARCELA".dplpar_tipo_pagto AS DUPLICATA_PARCELA_dplpar_f7e8,
 "DUPLICATA_PARCELA".dpl_loja AS DUPLICATA_PARCELA_dpl_loja,
 "DUPLICATA_PARCELA".dplpar_tipo AS DUPLICATA_PARCELA_dplpar_tipo,
 "DUPLICATA_PARCELA".dplpar_data_vencto AS DUPLICATA_PARCELA_dplpar_4402,
 "DUPLICATA_PARCELA".dplpar_parcela AS DUPLICATA_PARCELA_dplpar_623b,
 "DUPLICATA_PARCELA".dplpar_valor_pago AS DUPLICATA_PARCELA_dplpar_21aa,
 "DUPLICATA_PARCELA".dplpar_valor_juros AS DUPLICATA_PARCELA_dplpar_cd7f,
 "DUPLICATA_d167".dpl_valor_total AS DUPLICATA_d167_dpl_valor_f629,
 "DUPLICATA_d167".dpl_loja AS DUPLICATA_d167_dpl_loja,
 "DUPLICATA_d167".dpl_razao_social AS DUPLICATA_d167_dpl_razao_7640,
 "DUPLICATA_d167".dpl_cnpj_cpf AS DUPLICATA_d167_dpl_cnpj_cpf,
 "DUPLICATA_d167".dpl_valor_total_pago AS DUPLICATA_d167_dpl_valor_f046,
 "DUPLICATA_d167".dpl_data_emissao AS DUPLICATA_d167_dpl_data__5d35,
 "DUPLICATA_d167".dpl_ticket AS DUPLICATA_d167_dpl_ticket,
 "DUPLICATA_d167".dpl_id AS DUPLICATA_d167_dpl_id,
 "DUPLICATA_d167".dpl_documento AS DUPLICATA_d167_dpl_documento,
 "DUPLICATA_PARCELA".dplpar_valor AS DUPLICATA_PARCELA_dplpar_c7bf,
 "DUPLICATA_PARCELA".dpl_id AS DUPLICATA_PARCELA_dpl_id,
 "DUPLICATA_PARCELA".dplpar_perc_juros AS DUPLICATA_PARCELA_dplpar_adf7,
 "DUPLICATA_PARCELA".dplpar_data_vencto_orig AS DUPLICATA_PARCELA_dplpar_f78f
FROM
 "DUPLICATA_PARCELA"
 LEFT OUTER JOIN "DUPLICATA" AS "DUPLICATA_d167" ON
"DUPLICATA_d167".dpl_loja = "DUPLICATA_PARCELA".dpl_loja AND
"DUPLICATA_d167".dpl_id = "DUPLICATA_PARCELA".dpl_id
ORDER BY
 "DUPLICATA_PARCELA".dpl_loja,
 "DUPLICATA_d167".dpl_loja


And that "DUPLICATA" AS "DUPLICATA_d167" is my problem...

If I turn off eager loading, everything runs fine...

Thanks

Roger



On 10/5/06, Ezio Vernacotola <[EMAIL PROTECTED]> wrote:
> I don't understand what you are trying do to with column and table aliasing.
> Can you give some code example to better explain your problem?
>
> Ezio
>
>
>
>
>
> Roger Demetrescu wrote:
> > Hi,
> >
> > Firebird 1.5 allows the following sentences:
> >
> > select myfield from mytable;
> > select myfield FOO from my table;
> > select myfield AS FOO from mytable;
> >
> > (the last 2 sentences change the name of the final column, right ?)
> >
> >
> > The same rules don't apply when we create tables aliases:
> >
> > select myfield from mytable BAR;     => this works
> > select myfield from mytable AS BAR;     => this doesn't work
> >
> >
> > Is there any way to make SA avoid to use this " as " sintaxe when
> > aliasing table names ?
> > I am trying to use 2 mapped objects, with relation(..., lazy=False),
> > and I am getting FB's error:
> >
> > "Token unknown"
> >
> > just because " as "  is been used in the SQL generated by SA...    :(
> >
> >
> > BTW, I have also tried do use quote=False in Table() declaration, but
> > it seems to not have any  influence... am I missing something ?
> >
> >
> > Please let me know if you need more details...
> >
> > Cheers,
> >
> > Roger
> >
> > -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share your
> > opinions on IT & business topics through brief surveys -- and earn cash
> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Sqlalchemy-users mailing list
> > Sqlalchemy-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
> >
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to