-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Il 08/11/2012 00:32, Michael Bayer ha scritto:
> 
> On Nov 7, 2012, at 6:18 PM, Manlio Perillo wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
> 
>> Hi.
> 
>> When selecting against joined tables, SQLAlchemy always use the
>> "ON join_condition" form.
> 
>> The problem with this is that when the joined columns have the same
>> name, they are included 2 times in the result set.
> 
> Only if you select all of those columns.
> There's no need to resort to side effects of unusual SQL syntaxes
> here, if you're already using the expression language to generate
> joins, then you should be specifying those columns you care
> about selecting when you call select().

I care about selecting all columns, but without having duplicates.
And this is currently not possible, unless I use `use_labels` or manual
labels.

> Instead of passing "*" to select(), pass the Table object you care
> about. The names of the columns should be the least important
> thing here - the expression language deals in Table and Column
> objects first and foremost.
> 

Maybe I'm missing something:
http://paste.org/56806

when executing the output is (SQLAlchemy 0.7.7):
2012-11-08 12:49:29,274 INFO sqlalchemy.engine.base.Engine SELECT
foo.id, foo.x, bar.a, bar.id
FROM foo JOIN bar ON foo.id = bar.id
2012-11-08 12:49:29,280 INFO sqlalchemy.engine.base.Engine ()
(u'ID', 777, 0, u'ID')
[u'id', u'x', u'a', u'id']
Traceback (most recent call last):
  File "ambiguous.py", line 41, in <module>
    print r[0]['ID']
sqlalchemy.exc.InvalidRequestError: Ambiguous column name 'ID' in result
set! try 'use_labels' option on select statement.

How can I avoid this exception?
use_labels is not an option, for me, and manually settings labels in
order to avoid ambiguos columns is a bit of nuisance (I'm actually doing
this).



Thanks   Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlCbnmQACgkQscQJ24LbaUQcWACfYezfKV3NXDnCFO4VXVBCXvwn
Tb4AmwdLa/0XtHxaSWDzl/YamInjKOHF
=mLiB
-----END PGP SIGNATURE-----

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