-
Notifications
You must be signed in to change notification settings - Fork 69
Description
I want to implement a soft delete in one of my Resources. First choice would have been use Eve's soft delete but it is not possible because of #109 (#167).
I tried to implement a Flask-SQL Alchemy solution as proposed by Flask' contributor Miguel Grindberg:
https://github.com/miguelgrinberg/sqlalchemy-soft-delete/blob/master/app.py
I tried to define the query_class in several places: db.Model, the model, the Abstract clas, declarative_base... A sample of it is:
class CommonColumns(Base):
_deleted = Column(Boolean, default=False, nullable=False)
query_class = QueryWithSoftDeleteHowever, the query class ends up being flask-sqlalchemy's BaseQuery. Could it be that eve-sqlalchemy is forcing it, instead of allowing the custom query_class? Any direction on this item could be very helpful.
There is a difference that might be important for this, my models inherit from Base=sqlalchemy.ext.declarative.declarative_base() while flask-sqlalchemy typicall boilerplate models inherit from db.Model wher db=flask_sqlalchemy.SQLAlchemy().
I also tried to hardcoded the queryclass in Eve-sqlalchemy db init:
db = flask_sqlalchemy.SQLAlchemy(query_class=QueryWithSoftDelete)`` but I get the following error: sqlalchemy.exc.InvalidRequestError: Query.select_from() being called on a Query with existing criterion.```
While I would like to be able to define a custom query_class for any case scenario, I would be happy to look into allow Eve's soft delete, so I would be open to contribute provide some guidance.
Thanks for any help!