Revolution1 / Flask-WhooshAlchemyPlus

Whoosh indexing capabilities for Flask-SQLAlchemy, Flask-WhooshAlchemy plus some improvement

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Working without Flask_sqlalchemy

phuicy opened this issue · comments

So currently this plugin won't work without Flask-sqlalchemy. Specifically, if you sqlalchemy-utils.

Solution:
This section:

# change the query class of this model to our own

is changed to:

    # change the query class of this model to our own
    if hasattr(model, 'query_class'):
        if model.query_class is not flask_sqlalchemy.BaseQuery \
                and model.query_class is not _QueryProxy:
            print(model.query_class, _QueryProxy)
            model.query_class = type(
                'MultipliedQuery', (model.query_class, _QueryProxy), {}
            )
        else:
            model.query_class = _QueryProxy
    else:
        model.query_class = _QueryProxy