Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F3AACCBCB for ; Sat, 22 Nov 2014 14:42:42 +0000 (UTC) Received: (qmail 28863 invoked by uid 500); 22 Nov 2014 14:42:42 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 28835 invoked by uid 500); 22 Nov 2014 14:42:42 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 28824 invoked by uid 99); 22 Nov 2014 14:42:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Nov 2014 14:42:42 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.220.49] (HELO mail-pa0-f49.google.com) (209.85.220.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Nov 2014 14:42:38 +0000 Received: by mail-pa0-f49.google.com with SMTP id eu11so6685566pac.8 for ; Sat, 22 Nov 2014 06:41:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=mk5IXza5YjLneJ6R6MBD1NpPTUMqo2sCAxp5uhI1Ows=; b=l/ql8WE4eK+3ieO23edlnxhx8hDmqf5tVj7m6RqwOs0lZdphyvzh++VwGkGHc4RYqH R/S++4rsdX912rMuEPIwlEhkjyZNlhPYaIz+u5RUsZLDkUjqiJEWjdtRBa4/PiwTy6h+ naoTLwvh4DW6GU/NJE3iFa2DAprdYCeY1e1O7UOzDs2QqClcIePIEatB1XNXu7JLcJt7 0Tao8AjZtUOEYY+wxrLHPsU4MHNOlmbpo41e+bpOySAgAhaMErs0vH9BkcC4ijL1KWqk UfgAw8Jc8B1qQgT/ZLFq7iHn9/E3baIphXX44OwmidxeIhdn10To+/Wev552Ll4Ae8UJ Crng== X-Gm-Message-State: ALoCoQm9f9gwexil+S24r2yVTQJeg+dpBh/IxDs7PetOKZ0w69Iab4t6c3/BTDmw2KDJHQaw+xC8 X-Received: by 10.70.14.4 with SMTP id l4mr17321945pdc.56.1416667292592; Sat, 22 Nov 2014 06:41:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.70.10.227 with HTTP; Sat, 22 Nov 2014 06:41:12 -0800 (PST) In-Reply-To: <4279E9A3-B8A5-41A9-A688-CF8365019DCE@objectstyle.org> References: <1094EEAA-6205-4FAB-B789-E460A3078E4F@objectstyle.org> <1C50C7D9-B17F-429B-9A81-53268B73702E@objectstyle.org> <4279E9A3-B8A5-41A9-A688-CF8365019DCE@objectstyle.org> From: Michael Gentry Date: Sat, 22 Nov 2014 09:41:12 -0500 Message-ID: Subject: Re: Variations of 'like' To: Cayenne Developers Content-Type: multipart/alternative; boundary=047d7bdc1910bd87c70508738ebe X-Virus-Checked: Checked by ClamAV on apache.org --047d7bdc1910bd87c70508738ebe Content-Type: text/plain; charset=UTF-8 Yeah, but an ORM shields me from that. :-) On Sat, Nov 22, 2014 at 7:02 AM, Andrus Adamchik wrote: > FWIW PostgreSQL uses "ILIKE" for that purpose. > > > On Nov 22, 2014, at 2:43 PM, Andrus Adamchik > wrote: > > > > so, case sensitivity naming has its own inconsistencies already: > > > > ExpressionFactory.likeIgnoreCase(..) > > Property.likeInsensitive(..) // this is 4.0 API, we can change it > > > > I wonder if we should use the third shorter form going forward: > > > > likeI(..) # "I" is alluding to regex "i" flag. > > > > Thoughts? > > > > Andrus > > > > > > > >> On Nov 21, 2014, at 6:08 PM, Mike Kienenberger > wrote: > >> > >> Not only readability, but also picking the right options. > >> > >> For me, code completion on a method name is the quickest way to work > >> through chained query options. An enum argument is also workable, > >> but extra typing. But a generic type like int or boolean makes it > >> difficult to figure out what to specify without looking up the > >> documentation. > >> > >> On Fri, Nov 21, 2014 at 10:02 AM, Andrus Adamchik > >> wrote: > >>> enum also makes it needlessly verbose :-/ > >>> > >>> But yeah, I take your point. > >>> > >>> > >>>> On Nov 21, 2014, at 5:56 PM, Michael Gentry > wrote: > >>>> > >>>> I'd avoid true/false for that purpose. We had the same thing in > >>>> orderings before I changed it to an enum. I'd specify it in the > >>>> method name or use an enum that makes sense when reading it. > >>>> > >>>> mrg > >>>> > >>>> > >>>> On Fri, Nov 21, 2014 at 9:47 AM, Andrus Adamchik < > andrus@objectstyle.org> wrote: > >>>>>> So are you thinking something like: > >>>>>> Artist.ARTIST_NAME.contains("Van")? > >>>>> > >>>>> yep. > >>>>> > >>>>>> Also, what about > >>>>>> case-insensitive? > >>>>> > >>>>> Probably as a second true/false argument? I started to dislike the > look of "likeIgnoreCase" recently :) > >>>>> > >>>>> Property.contains(string); > >>>>> Property.contains(string, true); > >>>>> Property.contains(string, false); > >>>>> > >>>>> > >>>>> Andrus > >>>>> > >>>>> > >>>>>> On Nov 21, 2014, at 5:33 PM, Michael Gentry > wrote: > >>>>>> > >>>>>> I 'like' this. > >>>>>> > >>>>>> So are you thinking something like: > >>>>>> Artist.ARTIST_NAME.contains("Van")? Also, what about > >>>>>> case-insensitive? > >>>>>> > >>>>>> mrg > >>>>>> > >>>>>> > >>>>>> On Fri, Nov 21, 2014 at 7:19 AM, Andrus Adamchik < > andrus@objectstyle.org> wrote: > >>>>>>> Another API idea that I just had while analyzing boilerplate code > of the client Cayenne apps. An argument to Property.like(..) (or second > argument to ExpressionFactory.likeExp(..)) requires a full pattern to match > against. So people would often write their own utility code to wrap a > String in "%" signs. Cayenne can easily take care of this via the following > methods: > >>>>>>> > >>>>>>> > >>>>>>> Property.contains(string); > >>>>>>> // same as Property.like("%" + string + "%"); > >>>>>>> > >>>>>>> Property.startsWith(string); > >>>>>>> // same as Property.like(string + "%"); > >>>>>>> > >>>>>>> Property.endsWith(string); > >>>>>>> // same as Property.like("%" + string); > >>>>>>> > >>>>>>> In addition to saving the user from String concatenation, these > new methods can do proper symbol escaping, making "like" much safer to use. > >>>>>>> > >>>>>>> Andrus > >>>>>> > >>>>> > >>>> > >>> > >> > > > > > > --047d7bdc1910bd87c70508738ebe--