[docs]defis_already_joined(my_class,query):""" Check if the given class is already present is the current query _class: SQLAlchemy class query: SQLAlchemy query return boolean """forvisitorinvisitors.iterate(query.statement):# Checking for `.join(Parent.child)` clausesifvisitor.__visit_name__=="binary":forvisinvisitors.iterate(visitor):# Visitor might not have table attributewithsuppress(AttributeError):# Verify if already present based on table nameifmy_class.__table__.fullname==vis.table.fullname:returnTrue# Checking for `.join(Child)` clausesifvisitor.__visit_name__=="table":# Visitor might be of ColumnCollection or so,# which cannot be compared to modelwithsuppress(TypeError):ifmy_class==visitor.entity_namespace:returnTrue# Checking for `Model.column` clausesifvisitor.__visit_name__=="column":withsuppress(AttributeError):ifmy_class.__table__.fullname==visitor.table.fullname:returnTruereturnFalse