cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <>
Subject Re: split expressions
Date Wed, 13 Jan 2010 12:38:35 GMT
On 13/01/10 11:14 PM, Andrus Adamchik wrote:
> On Jan 13, 2010, at 2:02 PM, Andrus Adamchik wrote:
>> paintings.exhibits.start > $date1 AND like 'X%'
>> OR
>> paintings.exhibits.start < $date2 AND like 'Y%'
>> OR
>> paintings.exhibits.start = $date3 AND like 'Z%'
>> here you can't describe the desired behavior with "|", but can with
>> aliases:
>> a.start > $date1 AND like 'X%'
>> OR
>> b.start < $date2 AND like 'Y%'
>> OR
>> c.start = $date3 AND like 'Z%'
> Wonder if that's a bad example though, as the intended result can be
> obtained without splits... Need to think of a better one. Although the
> idea is that there can be cases when exact control over joins is needed.

And also, you could express that nicely using the syntax I proposed where each of the AND
operation was MERGE_PATH, and then the expressions ORed together with SPLIT_PATH. But I do
see how aliases are more flexible (since any part of the final expression can contain paths
which are merged and those which are not, even if they aren't directly merged as a pair of
expressions). But trying to think of a use case that would not make a sane developer's head
implode.... ?

I've tried to explain the current usage better in the docs, given what I now understand. Please
let me know if I misunderstood something. I had originally thought they were there as shortcuts
to a path string.

A way think of aliases is that they are markers within part of an expression which give Cayenne
hints about merging. Like a query cache key, they are important only if you use the same key
twice. But because aliases are created when you create the Expression path string, and then
expanded when you construct the query, they can be awkward to use. It would be nicer if the
Expression carried not only the idea of the key, but also how it expands and passed that onto
the query.

   Expression e1 ="path1|", "foo");
   Expression e2 ="path2|", "bar");

This puts the definition of the alias and the expansion in the same logical place. It would
also allow

   Expression e2 ="path2|", "bar");

to use the alias previously defined. Or to have Cayenne construct an arbitrary random, non-reusable

   Expression e1 ="|", "foo");

Then you could even define an expression

   Expression e1 = Expression.fromString("| = foo and |
= bar")

Is this making some forward progress?


Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

View raw message