Re: [sqlalchemy] ORM: LEFT JOIN LATERAL() ON TRUE

2018-03-01 Thread Mike Bayer
On Thu, Mar 1, 2018 at 6:34 PM, Adam Olsen wrote: > On Wed, Feb 28, 2018 at 3:44 PM, Adam Olsen wrote: >> >> I am trying to replicate the following raw query: >> >> SELECT r.id, r.name, e.id, e.title, e.start, e.end >> FROM room r >> LEFT JOIN LATERAL ( >> SELECT evt.id, evt.t

Re: [sqlalchemy] ORM: LEFT JOIN LATERAL() ON TRUE

2018-03-01 Thread Adam Olsen
On Wed, Feb 28, 2018 at 3:44 PM, Adam Olsen wrote: > I am trying to replicate the following raw query: > > SELECT r.id, r.name, e.id, e.title, e.start, e.end > FROM room r > LEFT JOIN LATERAL ( > SELECT evt.id, evt.title, evt.start, evt.end > FROM event evt, calendar c

Re: [sqlalchemy] ORM: LEFT JOIN LATERAL() ON TRUE

2018-03-01 Thread Adam Olsen
On Wed, Feb 28, 2018 at 6:14 PM, Mike Bayer wrote: > > you want to LEFT OUTER JOIN on that LATERAL so you'd want to use > query.outerjoin, somthing like: > > from sqlalchemy import true > > session.query(...).outerjoin(event_include, > true()).filter(Room.company_id == company_id) > > Core is a li

Re: [sqlalchemy] ORM: LEFT JOIN LATERAL() ON TRUE

2018-02-28 Thread Mike Bayer
On Wed, Feb 28, 2018 at 5:44 PM, Adam Olsen wrote: > I am trying to replicate the following raw query: > > SELECT r.id, r.name, e.id, e.title, e.start, e.end > FROM room r > LEFT JOIN LATERAL ( > SELECT evt.id, evt.title, evt.start, evt.end > FROM event evt, calendar ca

[sqlalchemy] ORM: LEFT JOIN LATERAL() ON TRUE

2018-02-28 Thread Adam Olsen
I am trying to replicate the following raw query: SELECT r.id, r.name, e.id, e.title, e.start, e.end FROM room r LEFT JOIN LATERAL ( SELECT evt.id, evt.title, evt.start, evt.end FROM event evt, calendar cal WHERE r.calendar_id=cal.id AND evt.calendar