I have some code:
def search(name: str = None):
q = db.query(City).join(Street)
if name:
q.filter(City.name==name)
return q.all()
But it doesn't add a condition to my query and returns all the results. How in SQLAlchemy can I split the query into conditions?