On Jan 13, 2010, at 12:45 PM, Aristedes Maniatis wrote:
> Split paths can already be added to the Path with "|" in some
> circumstances. They can be added to the Expression with matchAll().
> And in this case, they are deeply relevant to the AND because that's
> what the developer cares about. Do they get zero results when
> searching across a many join (which you always do with ANDed
> expressions and no split path)? Merging the path is never useful
> when you are ANDing two expressions.
Actually the following AND expression with reused joins is very common:
artist.name = 'X' AND artist.dob = $date
Also "|" notation only works for a single repeated path (hence
'matchAll()'). This is a very specific case. It is ambiguous in a
general case as it doesn't allow to do join groupings, only split vs.
shared. E.g.:
paintings.exhibits.start > $date1 AND paintings.exhibits.name like
'X%'
OR
paintings.exhibits.start < $date2 AND paintings.exhibits.name like
'Y%'
OR
paintings.exhibits.start = $date3 AND paintings.exhibits.name like
'Z%'
here you can't describe the desired behavior with "|", but can with
aliases:
a.start > $date1 AND a.name like 'X%'
OR
b.start < $date2 AND b.name like 'Y%'
OR
c.start = $date3 AND c.name like 'Z%'
> It seems that aliases (used in this way) are merely a workaround to
> the fact that Expressions need to know whether they should have
> their paths combined or not.
Aliases were designed specifically to control joins. This is not a
workaround, it is their intended use. There can be other uses for them
in the future if we start merging EJBQL and SelectQuery, but for now
their only intention is to control joins.
Now the goal is to evolve this further from just "working" API to
"user-friendly".
> It is not immediately obvious to me why not. I guess I tend to think
> of Path == Expression, since I always always create expressions
> using matchExp() and friends. But what happens now if you AND an
> expression created with matchAll with another expression with an
> overlapping path?
See examples above. Expression is a tree that has (1) "primitive"
clauses combined into (2) key/value expressions, and those combined
into (3) AND/OR/NOT conditional expressions with the arbitrary level
of nesting.
Andrus
This archive was generated by hypermail 2.0.0 : Wed Jan 13 2010 - 07:03:03 EST