A SportsClass
has many Courses
. I want to be able to only get the courses that are available.
I tried the following:
sports_classes = db.session.query(SportsClass).join(Course).filter((SportsClass.description.contains(query))|(SportsClass.name.contains(query)))
sports_classes = sports_classes.filter((Course.bookable == "bookable") | (Course.bookable == "waitingList"))
However, the result returned by that query are (converted to json and simplified):
[
"description": "description",
"courses": [
{
"name": "Name",
"bookable": "waitingList",
},
{
"name": "Keine Angaben",
"bookable": "canceled",
}
],
}
]
Why is the canceled course also in the result set? How can I get just the available courses for each class?