cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Evgeny Ryabitskiy (JIRA)" <j...@apache.org>
Subject [jira] Closed: (CAY-1433) Change #chunk behaviour to skipe only null arguments (don't skip 0 or false)
Date Fri, 21 May 2010 20:36:17 GMT

     [ https://issues.apache.org/jira/browse/CAY-1433?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Evgeny Ryabitskiy closed CAY-1433.
----------------------------------

    Resolution: Fixed

fixed as improvement in 3.1
Behavior deferents from 3.0 but its better and less confusing.

> Change #chunk behaviour to skipe only null arguments (don't skip 0 or false)
> ----------------------------------------------------------------------------
>
>                 Key: CAY-1433
>                 URL: https://issues.apache.org/jira/browse/CAY-1433
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Core Library
>            Reporter: Evgeny Ryabitskiy
>            Assignee: Evgeny Ryabitskiy
>             Fix For: 3.1M1
>
>
> Just copy from mails.
> I took example from http://cayenne.apache.org/doc20/scripting-sqltemplate.html and extend
it so it use Boolean fields to show my problem.
> 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 that this condition
is skipper because #chunk is actually checking condition of $isDead.
> Same thing if I put 0 in $id it will be false.
> For me problematic that when I am going to filter ARTISTS with id == 1 or id == 10 it
is all ok I will got query:
> SELECT * from  ARTIST t0 WHERE id = ? [bind: 1 ]
> But if I am filtering with id == 0 (that is absolute valid column value) I got:
> SELECT * from  ARTIST t0
> But I was expecting:
> SELECT * from  ARTIST t0 WHERE id = ? [bind: 0 ]
>  Same for Boolean values.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message