In SQL if I provide a v_category="fiction" then it would return all fiction books, if we provide v_category=null then it would provide books from all categories:
select * from book where category = :v_category or :v_category is null
How do I do this in SQLAlchemy:
books = Book.query.filter(or_(category = v_category, v_category is None).all()
However since or_ only accepts arguments and not conditions, it throws an error:
".filter(or_(workscope = v_workscope, v_workscope is None)) ^
SyntaxError: positional argument follows keyword argument"