Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-28 Thread RonnyPfannschmidt
is there any general hook that allows to access a query before it is compiled and executed im wondering about attaching criterion's to all joins and tables that will need it On Friday, February 28, 2014 3:10:56 AM UTC+1, Michael Bayer wrote: or, if you totally just map that class to a SELECT

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-28 Thread Michael Bayer
the typical hooks are: Query subclass, @compiles on select(), or a connection or cursor execute event. On Feb 28, 2014, at 11:01 AM, RonnyPfannschmidt ronny.pfannschm...@gmail.com wrote: is there any general hook that allows to access a query before it is compiled and executed im

[sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread RonnyPfannschmidt
Hi, im working on a project where in many tables data can not be deleted, but only marked as deactivated, Propperly handling selection of active data for normal users and all data for admins is turning more and more tendious (in particular wrt relationship configuration) Im wondering if there

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread Simon King
On Thu, Feb 27, 2014 at 8:44 AM, RonnyPfannschmidt ronny.pfannschm...@gmail.com wrote: Hi, im working on a project where in many tables data can not be deleted, but only marked as deactivated, Propperly handling selection of active data for normal users and all data for admins is turning

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread RonnyPfannschmidt
im already aware of that, but it doesnt expand to relationships and other things basically i need it taken into account in a lot more places On Thursday, February 27, 2014 10:59:21 AM UTC+1, Simon King wrote: On Thu, Feb 27, 2014 at 8:44 AM, RonnyPfannschmidt ronny.pfa...@gmail.com

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread Simon King
That wiki page also links to: https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/GlobalFilter which is intended to work with relationships as well, but it seems a lot more complicated. Another option might be to map to a SELECT, rather than directly to a table.

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread Michael Bayer
Also in the relationship docs, see relationship to non primary mapper, which illustrates how to make ad-hoc relationships to subqueries, though typically relationship to target where deleted=false is just a custom primary join condition, a subquery is probably not needed here. Sent from my

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread RonnyPfannschmidt
the problem is that it shouldn't just be taken into account for relationships but all queries that operate on such a table with the flag On Thursday, February 27, 2014 3:22:29 PM UTC+1, Michael Bayer wrote: Also in the relationship docs, see relationship to non primary mapper, which

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread Michael Bayer
you have to roll it yourself. query subclass + relationship + whatever else. On Feb 27, 2014, at 10:35 AM, RonnyPfannschmidt ronny.pfannschm...@gmail.com wrote: the problem is that it shouldn't just be taken into account for relationships but all queries that operate on such a table with

Re: [sqlalchemy] How to automatically handle deletion flags

2014-02-27 Thread Michael Bayer
or, if you totally just map that class to a SELECT statement that includes the criterion, that will do it too. but then you’ll get a lot of SELECT subqueries you might not want. or, create a view using CREATE VIEW. then map to that. That is definitely the most simple and SQL efficient way