From 661a3d812a8ada3626c81228ee0e97622376615e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Fri, 10 Nov 2023 20:56:53 +0100 Subject: [PATCH] fixup! add join check function --- src/utils_flask_sqla/utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils_flask_sqla/utils.py b/src/utils_flask_sqla/utils.py index 764c289..347b35d 100644 --- a/src/utils_flask_sqla/utils.py +++ b/src/utils_flask_sqla/utils.py @@ -35,6 +35,7 @@ def __enter__(self): copyfileobj(response, remote_file) return remote_file_path + def is_already_joined(my_class, query): """ Check if the given class is already present is the current query @@ -44,7 +45,7 @@ def is_already_joined(my_class, query): """ for visitor in visitors.iterate(query.statement): # Checking for `.join(Parent.child)` clauses - if visitor.__visit_name__ == 'binary': + if visitor.__visit_name__ == "binary": for vis in visitors.iterate(visitor): # Visitor might not have table attribute with suppress(AttributeError): @@ -52,8 +53,8 @@ def is_already_joined(my_class, query): if my_class.__table__.fullname == vis.table.fullname: return True # Checking for `.join(Child)` clauses - if visitor.__visit_name__ == 'table': - # Visitor might be of ColumnCollection or so, + if visitor.__visit_name__ == "table": + # Visitor might be of ColumnCollection or so, # which cannot be compared to model with suppress(TypeError): if my_class == visitor.entity_namespace: @@ -63,4 +64,4 @@ def is_already_joined(my_class, query): with suppress(AttributeError): if my_class.__table__.fullname == visitor.table.fullname: return True - return False \ No newline at end of file + return False