When I try to use both aliases and labels, the results are not named
as expected.

Instead of being able to access the columns as <label-name>_<column-
name> it appears as <original-table-name>_<numeric-sequence>_<column-
name>

Thanks,
  Jack

Sample code follows:

parent = Table('parent', metadata,
    Column('id', INTEGER(), primary_key=True),
    Column('name', VARCHAR(length=128)),
    Column('first_id', INTEGER(),
        ForeignKey(u'child.id')),
  )

child = Table('child', metadata,
    Column('id', INTEGER(), primary_key=True),
    Column('name', VARCHAR(length=128))
  )

def test_labels1(conn):
    s = select([parent,child], use_labels=True)
    s = s.where(parent.c.first_id==child.c.id)
    return conn.execute(s).fetchone()

def test_alias1(conn):
    firstchild = child.alias()
    s = select([parent,firstchild], use_labels=True)
    s = s.where(parent.c.first_id==firstchild.c.id)
    return conn.execute(s).fetchone()

conn = engine.connect()

results = test_labels1(conn)
print results.parent_name
print results.child_name

results = test_alias1(conn)
print 'alias1 results: '
print results.parent_name
#print results.firstchild_name # expected this to work
print results.child_1_name # this worked instead

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to