Hello Michael,
I changed delete as you suggested.
def delete(self, synchronize_session='evaluate'):
columns = self.column_descriptions
# don't know to delete on multiple tables in
# the same statement
assert len(columns) == 1
entity = columns[0]
On Sep 21, 2011, at 9:53 AM, Andrei Chirila wrote:
> Hello,
>
> I looked closely at Query implementation and I ended up with this:
>
>
> def delete(self, synchronize_session='evaluate'):
> context = self._compile_context()
> assert len(context.statement.froms) == 1
>
Hello,
I looked closely at Query implementation and I ended up with this:
from sqlalchemy.orm.query import Query
import sqlalchemy.event as event
class DeletedAtQuery(Query):
""" Query adding a default condition that,
if deleted_at exists, it should be NULL
for the rows retu
On Sep 20, 2011, at 10:12 AM, Andrei Chirila wrote:
> Hello Michael,
>
> Thank you :)
>
> I changed the code according to your indications:
>
> def paranoid_delete(session, flush_context, instances):
> """ Intercepts item deletions (single item deletions)
> and, if there is a field
Hello Michael,
Thank you :)
I changed the code according to your indications:
def paranoid_delete(session, flush_context, instances):
""" Intercepts item deletions (single item deletions)
and, if there is a field deleted_at for that
object, it's updating deleted at instead of
On Sep 20, 2011, at 8:33 AM, Andrei Chirila wrote:
> Hello,
>
> I'm working at implementing a safe delete on my models (having a
> deleted_at field which is checked and setting a deleted_at field when
> a model is deleted).
>
> I looked over the LimitingQuery recipe and at
> SessionEvents.befor
Hello,
I'm working at implementing a safe delete on my models (having a
deleted_at field which is checked and setting a deleted_at field when
a model is deleted).
I looked over the LimitingQuery recipe and at
SessionEvents.before_flush and bellow is my solution. As I'm kind of
new SqlAlchemy user