cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Atli Páll Hafsteinsson <atlip...@gmail.com>
Subject Re: Type safe queries & more
Date Fri, 16 Sep 2011 10:23:39 GMT
For me a big part of the reason for implementing this is to get rid of
text based queries as they cannot be verified and therefore error
prone. Plus you have to know more about the data structure.


Atli Páll Hafsteinsson
atlipall@gmail.com



On Fri, Sep 16, 2011 at 9:35 AM, Aristedes Maniatis <ari@maniatis.org> wrote:
> On 16/09/11 6:57 PM, Durchholz, Joachim wrote:
>>
>>   User.fetch( dataContext,
>>     new Query(
>>       User.FIRSTNAME.like( "joe%" )
>>         .and(User.AGE.between( 20, 30 )))
>>     .sort( User.FIRSTNAME.asc().then( User.LASTNAME.asc() )
>>   )
>
> Another approach is to use the keys only as function parameters.
>
> User.where(User.FIRSTNAME, Query.LIKE, "joe%").and(User.AGE, Query.BETWEEN,
> "20,30").sort(User.FIRSTNAME, Query.ASC).sort(User.LASTNAME,
> Query.ASC).limit(10)
>
> or with strings:
>
> User.where("firstname LIKE joe%").and("age BETWEEN 20,30").sort("firstname
> ASC").sort("lastname ASC").limit(10)
>
>
> You could also pre-define qualifiers like this:
>
>  debtors = User.where("owing > 0)
>
> and then later on use it in this nice natural speech kind of way:
>
>  debtors.where("firstname LIKE joe%")
>
> All we need for this is to make .and() and .where() equivalent functions.
>
>
> Please reply to the dev@ list only.
>
> Thanks
> Ari
>
> --
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>

Mime
View raw message