[sqlalchemy] inner join and ambiguous columns

2010-03-19 Thread marco vaccari
Consider 3 tables A,B,C A JOIN B ON A.id = B.id produce all the columns required for an insert into C. I can write: C.insert().values(dict(zip(record.keys(), record.items())) With use_labels == True and fold_equivalents == False the above solution does not work because the join columns labels

Re: [sqlalchemy] inner join and ambiguous columns

2010-03-19 Thread Michael Bayer
On Mar 19, 2010, at 11:23 AM, marco vaccari wrote: Consider 3 tables A,B,C A JOIN B ON A.id = B.id produce all the columns required for an insert into C. I can write: C.insert().values(dict(zip(record.keys(), record.items())) With use_labels == True and fold_equivalents == False the

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-18 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: On Feb 17, 2010, at 9:56 AM, Manlio Perillo wrote: Michael Bayer ha scritto: [...] By the way, I have found an incorrect behaviour in SQLAlchemy, when the select column list is empty. query = sql.select( None,

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-18 Thread Michael Bayer
On Feb 18, 2010, at 6:02 AM, Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: On Feb 17, 2010, at 9:56 AM, Manlio Perillo wrote: Michael Bayer ha scritto: [...] By the way, I have found an incorrect behaviour in SQLAlchemy, when the select

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-18 Thread Michael Bayer
On Feb 18, 2010, at 10:18 AM, Michael Bayer wrote: Ok. My idea was to implement the equivalent of SQL '*' column. I can't use the literal '*' in the select column list, since it will disable (?) SQLAlchemy type system. And I don't want to manually add the columns, since I will end up with

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-18 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: On Feb 18, 2010, at 10:18 AM, Michael Bayer wrote: Ok. My idea was to implement the equivalent of SQL '*' column. I can't use the literal '*' in the select column list, since it will disable (?) SQLAlchemy type

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-17 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: On Feb 16, 2010, at 7:07 PM, Manlio Perillo wrote: Michael Bayer ha scritto: [...] just so I can understand fully can you modify the paste I sent to illustrate exactly how the results are happening, as that can help me

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-17 Thread Michael Bayer
On Feb 17, 2010, at 8:58 AM, Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: On Feb 16, 2010, at 7:07 PM, Manlio Perillo wrote: Michael Bayer ha scritto: [...] just so I can understand fully can you modify the paste I sent to illustrate

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-17 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: [...] By the way, I have found an incorrect behaviour in SQLAlchemy, when the select column list is empty. query = sql.select( None, contents.c.slug == 'python', from_obj=[join]) SQLAlchemy generates an

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-17 Thread Michael Bayer
On Feb 17, 2010, at 9:56 AM, Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: [...] By the way, I have found an incorrect behaviour in SQLAlchemy, when the select column list is empty. query = sql.select( None, contents.c.slug ==

[sqlalchemy] inner join and ambiguous columns

2010-02-16 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. Here is a simple example of using joins in SQLAlchemy: from sqlalchemy import schema, types, sql, create_engine metadata = schema.MetaData() x = schema.Table( 'x', metadata, schema.Column('id', types.Integer, primary_key=True),

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-16 Thread Michael Bayer
Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. Here is a simple example of using joins in SQLAlchemy: from sqlalchemy import schema, types, sql, create_engine metadata = schema.MetaData() x = schema.Table( 'x', metadata, schema.Column('id',

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-16 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: Manlio Perillo wrote: [...] query = sql.join(x, y).select() r = engine.execute(query).fetchone() [...] This code will raise an: sqlalchemy.exc.InvalidRequestError: Ambiguous column name 'id' in result set!

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-16 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: [...] Unfortunately, fold_equivalents is not a generic solution for me I have a generative query, where I later add the select_from object. The query is generative, since the tables involved are not know in advance. I

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-16 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: Manlio Perillo wrote: Here is the code I have: http://paste.pocoo.org/show/178959/ What each plugin do is: - add additional columns in the select list - add additional where clauses or order_by clauses I don't see

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-16 Thread Michael Bayer
Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: Manlio Perillo wrote: Here is the code I have: http://paste.pocoo.org/show/178959/ What each plugin do is: - add additional columns in the select list - add additional where clauses or order_by

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-16 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: [...] just so I can understand fully can you modify the paste I sent to illustrate exactly how the results are happening, as that can help me to formulate the best version of this feature. I have pasted a complete

Re: [sqlalchemy] inner join and ambiguous columns

2010-02-16 Thread Michael Bayer
On Feb 16, 2010, at 7:07 PM, Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Bayer ha scritto: [...] just so I can understand fully can you modify the paste I sent to illustrate exactly how the results are happening, as that can help me to formulate the best