clorm
clorm copied to clipboard
Bug in ordering for queries with multiple joins
When you have a query with multiple joins clorm's query planner can internally generate a plan where the join order is different to the order in the query specification. However, this is meant to be hidden from the API level and when outputting the result (or passing a function in the 'select` modifier) the order should match the order specified the in the query.
For example, given a factbase query joining predicates A,B,C,D,E
then passing a lambda
to the select
modifier should expect the fact instances to match the predicates. So:.
q = fb.query(A,B,C,D,E). ... .select(lambda a,b,c,d,e : ...)
where a
is of type A
, b
is of type B
, etc.
However, this doesn't seem to be working properly, and there are some cases where the result is not presented in the correct order and the lambda
in the select
is being passed the internal ordering of facts.
As a workaround it is possible to force a specific join order using the heuristic
modifier and clorm's fixed_join_order()
function. So:
from clorm import fixed_join_order
q = fb.query(A,B,C,D,E).heuristic(fixed_join_order(A,B,C,D,E)). ... .select(lambda a,b,c,d,e: ...)