Hi Evgeny,
Where did you find this example?
I am checking #chunk directive example here: http://cayenne.apache.org/doc20/scripting-sqltemplate.html
and everything seems correct to me. IIRC "0 == null" is how Velocity
evaluates expressions (C-style), so this has to be taken into account
when building SQLtemplates.
So I don't understand which parts you find problematic?
Cheers,
Andrus
On May 21, 2010, at 10:36 AM, ςΡΒΙΓΛΙΚ εΧΗΕΞΙΚ wrote:
> Hello, here is example from tutorial for 2.0:
>
> String sql = "SELECT DISTINCT"
> + " #result('ARTIST_ID' 'int'),"
> + " #result('ARTIST_NAME' 'String'),"
> + " #result('DATE_OF_BIRTH' 'java.util.Date')"
> + " #result('IS_DEAD' 'java.util.Boolean')"
> + " FROM ARTIST t0"
> + " #chain('OR' 'WHERE') // start
> chain prefixed by WHERE,
> // and joined
> by OR
> + " #chunk($name) ARTIST_NAME LIKE #bind($name) #end" //
> ARTIST_NAMEchunk"
> + " #chunk($id) ARTIST_ID > #bind($id) #end" // ARTIST_ID
> chunk"
> + " #chunk($isDead) IS_DEAD = #bind($isDead) #end" // IS_DEAD
> chunk"
> + " #end"; // end of chain
> SQLTemplate select = new SQLTemplate(Artist.class, sql, true);
>
>
> If I put in isDead true - everything is ok, but if I put false I got
> chat this condition is skipper because #chunk is actually checking
> condition of $isDead.
>
> Same thing if I put 0 in $id it will be false.
>
> So this example of tutorial is bad for Dead Artists or Artists with
> id == 0.
> Maybe it's a bug of #chunk directive and it should do only null
> check??
>
> Evgeny.
>
This archive was generated by hypermail 2.0.0 : Fri May 21 2010 - 08:12:22 UTC