Re: [sqlalchemy] standalone asc/desc function vs ColumnElement asc/desc function

2018-03-01 Thread Jonathan Vanasco
On Thursday, March 1, 2018 at 9:31:26 PM UTC-5, Mike Bayer wrote: not that I'm aware of. it's a matter of whichever is more convenient > given the kind of expression that is applied with DESC (e.g. a more > complex expression might look more natural enclosed in desc()). > I've had some

[sqlalchemy] Re: Performance of ORDER BY vs. list.sort() vs. sorted()

2018-03-01 Thread Jonathan Vanasco
This is going to wildly depend on how many things are being sorted, and what those things are. this topic usually a premature optimization or "you're doing it wrong". Imagine this query in Postgres: SELECT * FROM records WHERE ORDER BY timestamp_desc; If there are 1,000 items in the

[sqlalchemy] How to properly handle bidirectional many-to-many and their double entries

2018-03-01 Thread jens . troeger
Hi, I've been playing with the Many-to-Many relationship from the documentation. Suppose I have a student and teacher and would like to define a bidirectional “favorite” relationship between the two, i.e. if a

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

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

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 ==