Hello Michael, hello List,

thanks for your previous patch. Most queries of that type do work now.

I am sorry but I have to inform you that I stumbled upon another query 
which used these selects in a nested fashion, that triggered the bug. :-}

cheers,
Christoph

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/0yb7gY4d_BAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

#!/usr/bin/env python
# encoding: utf-8

# This is an illustration of a problem with column_properties used
# from within column_properties where the inner most column_property
# uses joined aliased tables.

from sqlalchemy import Table, Column, Integer, ForeignKey, MetaData
from sqlalchemy import select
from sqlalchemy.sql.util import _deep_deannotate

metadata = MetaData()

table1 = Table(
    'table1', metadata,
    Column('t1_id', Integer),
)

table2 = Table(
    'table2', metadata,
    Column('t2_id', Integer, primary_key=True),
    Column('t1_id', Integer, ForeignKey('table1.t1_id')),
)


mytable2 = table2.alias()

s = select(
    [
        _deep_deannotate(
            select(
                [
                    _deep_deannotate(
                        select(
                            [ mytable2.c.t2_id ],
                            from_obj=table1.join(mytable2)
                        ).as_scalar()
                    ),
                ]
            ).as_scalar()
        )
    ],
)

# Good
print s

# XXX Bad. Look at the FROM clause of this select
print _deep_deannotate(s)

Reply via email to