[sqlalchemy] Re: BakedQuery with function parameters

2016-10-24 Thread Anton Baranenko
Thank you Mike! This is indeed quite complex, I will try this and will write back on the results. Worst case I have a plan B which is to save the raw SQL, execute it without ORM and then hard code the mapping manually - luckily while the query structure is quite complex, the resulting entity

[sqlalchemy] BakedQuery with function parameters

2016-10-23 Thread Anton Baranenko
Hi all, based on the successful progress with my previous topic "Using BakedQuery with joined subqueries" (thanks again Mike!) I have the next question. For some of my queries conditions logic is generated based on certain parameters. For example, I have a JSONB field that contains custom

[sqlalchemy] Re: Using BakedQuery with joined subqueries

2016-10-23 Thread Anton Baranenko
Thank you Mike, worked as expected! > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.

[sqlalchemy] Using BakedQuery with joined subqueries

2016-10-22 Thread Anton Baranenko
Hi all, I'd like to ask for your help with implementing the following. I have quite a complex query with subqueries generated in the application. In general the structure would look like this: draft_data = aliased( Draft.query.filter( Draft.author_user_id == drafts_from_user_id #