From playing with variations of the query, the error seems to come from the second clause of the and inside the or-join. I don't know the internals of datascript, but my guess is that something like this has started happening:
✅ When ?x is bound to "alice", then because "alice"'s :parent is "bob", the first clause of the and binds ?z to "bob". Then the second clause of the and is run, and ?y is added to the relation. Since both ?x and ?y are bound by both parts of the or-join, they can be "summed".
❌ However, when ?x is bound to "clara", then because "clara" has no :parent, the first clause in the and has no tuples, and so the second clause is never "run", and ?y is never added to the relation. So, the first part of the or-join ends up with only ?x bound, which leads to the error when it's summed with the second part which has both ?x and ?y.
I'm upgrading from 1.6.3 to 1.6.4 and started getting a new exception with one of my queries
Can’t sum relations with different attrs
.I've created a reproduction. It's as small as I can make it, though it's still somewhat complicated.
In 1.6.3 this produces
In 1.6.4 it produces
From playing with variations of the query, the error seems to come from the second clause of the
and
inside theor-join
. I don't know the internals of datascript, but my guess is that something like this has started happening:?x
is bound to "alice", then because "alice"'s:parent
is "bob", the first clause of theand
binds?z
to "bob". Then the second clause of theand
is run, and?y
is added to the relation. Since both?x
and?y
are bound by both parts of theor-join
, they can be "summed".?x
is bound to "clara", then because "clara" has no:parent
, the first clause in theand
has no tuples, and so the second clause is never "run", and?y
is never added to the relation. So, the first part of theor-join
ends up with only?x
bound, which leads to the error when it's summed with the second part which has both?x
and?y
.