oh....well it was intended to be used this way :

s2 = s1.with_only_columns( [t.c.a, sa.func.length(t.c.a)] )

but I can see how you might think it works the way you're doing it....but i 
think that behavior would still be incorrect, i would think 
s1.with_only_columns([s1.c.foo, s1.c.bar]) would create a SELECT from itself, 
the way orm.query.from_self() does...but that's out of the scope of what 
with_only_columns() was going for.   Its just going for, make the select() as 
though you said select([a, b, c]) instead of select([a, b, c, d, e, f]).



On Jul 1, 2011, at 2:33 PM, Jon Nelson wrote:

> import sqlalchemy as sa
> e = sa.create_engine( 'sqlite:///' )
> conn = e.connect()
> m = sa.MetaData()
> m.bind = conn
> 
> t = sa.Table('a', m, sa.Column('a', sa.String()) )
> t.create()
> s1 = sa.select( [t.c.a, sa.func.length(t.c.a), t.c.a * 2 ] )
> cols = [ c for c in s1.c ]
> s2 = s1.with_only_columns( cols )
> print s1
> print s2
> conn.execute(s1)
> conn.execute(s2)

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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.

Reply via email to