If model has query, but it has no attribute filter, use session

Query is None for models with latest Flask-SQLAlchemy.
https://github.com/mitsuhiko/flask-sqlalchemy/blob/master/flask_sqlalchemy/__init__.py#L567