Re: [sqlalchemy] outerjoin condition matching tuples

2014-04-21 Thread Rick Otten
Interesting, and I had thought about it, but wouldn't that run the subquery (myselect) 3 times for each join? On Sunday, April 20, 2014 10:01:20 PM UTC-4, Michael Bayer wrote: there’s a way to get the tuple comparison to work here though it’s not as common, I’d have to try it out and there

Re: [sqlalchemy] outerjoin condition matching tuples

2014-04-21 Thread Michael Bayer
no, the SQL is SELECT ... FROM x JOIN y ON x.a=y.a AND x.b=y.b AND x.c=y.c On Apr 21, 2014, at 9:02 AM, Rick Otten rottenwindf...@gmail.com wrote: Interesting, and I had thought about it, but wouldn't that run the subquery (myselect) 3 times for each join? On Sunday, April 20, 2014

[sqlalchemy] outerjoin condition matching tuples

2014-04-20 Thread Rick Otten
I would like to apply a condition in an outer join that matches a multi-item list rather than a single value. In other words, I'm trying to get SQLAlchemy 0.8.6 connecting to PostgreSQL 9.3.4 to generate SQL like this: select * from mytable mt left outer join myothertable mo

Re: [sqlalchemy] outerjoin condition matching tuples

2014-04-20 Thread Michael Bayer
there's a way to get the tuple comparison to work here though it's not as common, I'd have to try it out and there might be some quirks to work out. I would think this would be more straightforward using a straight AND: and_(mo.c.col1 == myselect.c.col1, mo.c.col2 == myselect.c.col2, mo.c.col3

[sqlalchemy] outerjoin where first selected column is a literal dies with confusing error

2014-03-17 Thread Ryan Kelly
Hi: When I run the attached example, I get the following error: sqlalchemy.exc.NoInspectionAvailable: No inspection system is available for object of type type 'NoneType' Which is a result of literal(1) appearing first in the select list. I don't particularly care than I can't order my columns

Re: [sqlalchemy] outerjoin where first selected column is a literal dies with confusing error

2014-03-17 Thread Michael Bayer
when you do outerjoin() it will try to join from the first item in the list, unless you do select_from: query(literal(), X.foo, Y.bar).select_from(X).join(Y, ) will see what can be done about the error message On Mar 17, 2014, at 2:58 PM, Ryan Kelly rpkell...@gmail.com wrote: Hi:

Re: [sqlalchemy] outerjoin where first selected column is a literal dies with confusing error

2014-03-17 Thread Michael Bayer
the error message has been improved in 9ec01ab35a / 987759aec51e (0.9 / 0.8) On Mar 17, 2014, at 4:16 PM, Michael Bayer mike...@zzzcomputing.com wrote: when you do outerjoin() it will try to join from the first item in the list, unless you do select_from: query(literal(), X.foo,

[sqlalchemy] outerjoin

2011-01-26 Thread Pankaj
Hi, I have this subquery, which yields results sp_HeaderDetails = session.query( InvoiceCashFlowPerDocNum.sequence_id, InvoiceHeaderInfo.invoice_ref, InvoiceHeaderInfo.doc_num ) \ .filter( ( InvoiceCashFlowPerDocNum.doc_num == InvoiceHeaderInfo.doc_num ) ) \

Re: [sqlalchemy] outerjoin

2011-01-26 Thread Michael Bayer
On Jan 26, 2011, at 11:46 AM, Pankaj wrote: Hi, I have this subquery, which yields results sp_HeaderDetails = session.query( InvoiceCashFlowPerDocNum.sequence_id, InvoiceHeaderInfo.invoice_ref, InvoiceHeaderInfo.doc_num ) \ .filter( (

[sqlalchemy] outerjoin in mapper

2008-10-29 Thread jack2318
Hi, I have 3 tables - tbl_item, tbl_item_sku, and tbl_item_lot Table tbl_item has 2 FKs my mapper is pretty simple: mdbItem = mapper(dbItem, tbl_item, properties={ 'sku': relation(dbItemSKU,

[sqlalchemy] Outerjoin on Subselect?

2007-09-09 Thread Aaron R
Hello all; I am trying to do a subselect on an Outer join. I have a table of votes that can apply to multiple objects in my system so their is no direct foreign key. A Voteable type implementation. When i load the list of Projects, i want to return the current users votes eagerly if possible,

[sqlalchemy] outerjoin constructor throws exception from 0.3.9. Bug or user error?

2007-08-27 Thread mc
Hi, I have the following two tables (in MySql): CREATE TABLE `A` ( `xkey` varchar(200) NOT NULL, `yval` int(11) default NULL, PRIMARY KEY (`xkey`) ) ENGINE=InnoDB; and CREATE TABLE `B` ( `xkey` varchar(200) NOT NULL default '', `s` enum('yes','no') NOT NULL default 'yes', PRIMARY

[sqlalchemy] Outerjoin with a subset of columns

2007-08-15 Thread mc
Hi, Note the following code: oj=outerjoin(s,f) r1=select([oj]).execute().fetchall() r2=select([oj.left.c.id, oj.right.c.status]).execute().fetchall() The first select executes a LEFT OUTER JOIN and returns all columns. I wanted only 2 specific columns, so I tried the 2nd select. That does not