05-29-2020, 10:48 PM
I honestly don't know why "add_relationship_filter" does not use "add_relationship_filters". Somehow, it was implemented as a separate function with ever so slightly different logic and nobody really noticed until now.
It looks like 4.8 is trying to use joins, which is much faster and more scalable that the 4.5 method, but this breaks down when a table is joining to itself. It uses "asset" twice and the name becomes ambiguous. The SQL that I printed in my last post is what it should be. Not how I change the namespace of the second use of the asset table to "asset2" (or whatever name). This is a problem only when a table is trying to reference itself.
This is where "add_relationship_filters" breaks. There is a slight line difference:
In 4.5:
861 if search_type == related_type:
In 4.8:
911 if search_type == related_type and not attrs:
In 4.5, it ignored the relationship where as in 4.8 it tries to handle it. However, if the type is instance, this will break.
Try this:
911 if search_type == related_type and (not attrs or attrs.get("relationship") == "instance"):
This will use the 4.5 implementation for instance relationships for a table to itself. Until we can get the instance SQL to work as in my previous post, we will have to use the inefficient method.
Let me know if it works!
It looks like 4.8 is trying to use joins, which is much faster and more scalable that the 4.5 method, but this breaks down when a table is joining to itself. It uses "asset" twice and the name becomes ambiguous. The SQL that I printed in my last post is what it should be. Not how I change the namespace of the second use of the asset table to "asset2" (or whatever name). This is a problem only when a table is trying to reference itself.
This is where "add_relationship_filters" breaks. There is a slight line difference:
In 4.5:
861 if search_type == related_type:
In 4.8:
911 if search_type == related_type and not attrs:
In 4.5, it ignored the relationship where as in 4.8 it tries to handle it. However, if the type is instance, this will break.
Try this:
911 if search_type == related_type and (not attrs or attrs.get("relationship") == "instance"):
This will use the 4.5 implementation for instance relationships for a table to itself. Until we can get the instance SQL to work as in my previous post, we will have to use the inefficient method.
Let me know if it works!