cloning bug in select
Issue #2453
resolved
#!/usr/bin/env python
# encoding: utf-8
# This is an illustration of a problem with column_properties where
# the from_obj contains joined aliased tables.
from sqlalchemy import Table, Column, Integer, ForeignKey, MetaData
from sqlalchemy import select
from sqlalchemy.sql.util import _deep_deannotate
metadata = MetaData()
orders = Table(
'orders', metadata,
Column('order_id', Integer, primary_key=True),
)
item = Table(
'item', metadata,
Column('item_id', Integer, primary_key=True),
Column('order_id', Integer, ForeignKey('orders.order_id')),
)
a = item
b = a.outerjoin(orders)
s = select([a.c.item_id](a.c.item_id), from_obj=b)
a = item.alias()
b = a.outerjoin(orders)
s = select([a.c.item_id](a.c.item_id), from_obj=b)
print s
# XXX Not OK. Look at the FROM clause of this select
print _deep_deannotate(s)
Comments (5)
-
reporter -
reporter - changed status to resolved
this was addressed instead at the annotation level, by maintaining a unique copy of the Alias instead of multiple. 45046367f34ee2dadb98024b0f2b05248459f978
-
reporter - changed status to open
- removed status
OK we still need to do that extra "toremove" logic for the case where _deep_deannotates are nested....
mytable2 = table2.alias() s = select( [ _deep_deannotate( select( [ _deep_deannotate( select( [ mytable2.c.t2_id ]( ), from_obj=table1.join(mytable2) ).as_scalar() ), ] ).as_scalar() ) ], )
which would be if you're nesting column_property() objs together
another razor thin edge ..
-
reporter - changed status to resolved
okey doke 1378bf0d25319f3725cfe8ff947a5f0aeae4cc81
-
reporter - removed milestone
Removing milestone: 0.7.7 (automated comment)
- Log in to comment
patch: