Dustin,
On Sep 2, 7:01 am, Dustin <
dsalli...@gmail.com> wrote:
> I disagree that the inline join is aligned with the pipeline
> interpretation unless you want multiple where clauses as well, because
> that's pretty well what ON is, isn't it? You're effectively saying combine
> both of these things. Then you're effectively filtering *both* of them by a
> particular condition. I think it's easy to look at this either way. It
> would, however, be difficult to *disallow* filtering joins in the WHERE
> clause, so making more than one way to do it seems a bit undesirable.
If all joins are "inner" joins, then you're indeed looking at a
combination of all collections with each other, and in that case I
agree that it only boils down to preference where you write the
conditions.
But if it should be possible to have outer joins like in SQL, then
suddenly the order of the collections does matter, and the semantics
of conditions appearing in the ON clause are slightly different then
those appearing in the WHERE clause.
I mean this, suppose we have
collection A: [{a: 1}, {a: 2}] and collection B [{b: 1}]
then:
SELECT {a: A.a, b: B.b}
FROM A, B
WHERE A.a = B.b
would give only one result {a: 1, b: 1}, because only {a: 1} matches
{b: 1} and a syntax using JOIN..ON like this
SELECT {a: A.a, b: B.b}
FROM A JOIN B ON A.a = B.b
would yield exactly the same result. But if it would be an outer join
the reslt would be different:
SELECT {a: A.a, b: B.b}
FROM A LEFT JOIN B ON A.a = B.b
would give two result documents, [{a:1, b:1}, {a: 2, b: null}]
And if we would add a WHERE like this:
SELECT {a: A.a, b: B.b}
FROM A LEFT JOIN B ON A.a = B.b
WHERE B.b === null
then the result would be {a:2, b:null},
This outcome is very different from the case where both conditions
would appear in either the ON or the WHERE:
SELECT {a: A.a, b: B.b}
FROM A LEFT JOIN B ON A.a = B.b && B.b === null
would yield no data at all, because there is no document in B with b
=== null.
And for the same reason,
SELECT {a: A.a, b: B.b}
FROM A LEFT JOIN B
WHERE A.a = B.b && B.b === null
would also return no data.
So if we put aside all arguments about explicitness, the explicit
JOIN...ON syntax is functionally different from the comma join, at
least in case UnQL is to support outer joins.
kind regards,
Roland