Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5AD43200B67 for ; Tue, 16 Aug 2016 13:25:31 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5965F160AA8; Tue, 16 Aug 2016 11:25:31 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 78657160A76 for ; Tue, 16 Aug 2016 13:25:30 +0200 (CEST) Received: (qmail 9335 invoked by uid 500); 16 Aug 2016 11:25:24 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 8060 invoked by uid 99); 16 Aug 2016 11:25:22 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Aug 2016 11:25:22 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 8AE61C19FE for ; Tue, 16 Aug 2016 11:25:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.821 X-Spam-Level: X-Spam-Status: No, score=-0.821 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=objectstyle.org header.b=j4L+VYyg; dkim=pass (1024-bit key) header.d=messagingengine.com header.b=Tb62WCtZ Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 4K0KzSpLoy0G for ; Tue, 16 Aug 2016 11:25:20 +0000 (UTC) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id CBF155FC38 for ; Tue, 16 Aug 2016 11:25:19 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 4E40F20547 for ; Tue, 16 Aug 2016 07:25:08 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute3.internal (MEProxy); Tue, 16 Aug 2016 07:25:08 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=objectstyle.org; h=content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=YCRrUpIMiAz0Pqr8uPCtFVhMi38=; b=j4L+VY ygv6Ei8xJIohjDPJ349P+3TXPDrAN1u1TfClOSjOzDG6Ff9YEUFow87Rpl0ENe/L C+k0pdmNt9KV52tBRLbLIhuWi/nzGIZyvWZJma3S9KOoPbgz1iAQqIRTx4K+YLDf JGYpTHj6+ZVAlXps6thDmjRQJ0vozFV++eJEQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=YCRrUpIMiAz0Pqr 8uPCtFVhMi38=; b=Tb62WCtZR8IAGbJjeu3Knlr6cJHOlkAmMtMJSFg7Tmge0Yv OhzZZ3w83rVc7p3PJHUtzRnADaCQxQ3AiVEa5mIvtLCgVaAMfWqTuympuCIdanLF IbhsBEz/dTB6s9QtgURVORM7o6eSppuwxbp7Es9tHGJJUentjpEiGMVBg4nA= X-Sasl-enc: HfmGz3HnH7+Qs/oeDg3iDO5wXQVqZmnCud8slKXet8wX 1471346707 Received: from [192.168.1.52] (unknown [37.17.49.228]) by mail.messagingengine.com (Postfix) with ESMTPA id B3F53CCDCC for ; Tue, 16 Aug 2016 07:25:07 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: EJBQL: Arithmetic operations From: Andrus Adamchik In-Reply-To: Date: Tue, 16 Aug 2016 14:25:06 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <0D5F800F-7267-4D89-8729-D0E64AA36FA4@objectstyle.org> References: <43B9FC97-D422-479D-A745-9FF7AB702092@karlmenn.is> <95DA1376-6BF9-4890-AA00-842F72BED149@objectstyle.org> <5A8CC9BA-C43C-4A1B-9A6A-E9A4650F5BCF@karlmenn.is> <2C2E010B-EAD5-4108-BDCC-F66C1183EE07@karlmenn.is> <4B81A3AD-7AD8-4F06-AE6C-C2AC1254EED4@objectstyle.org> <7EA8AF13-2E5D-454D-B876-0CC1AAFBAC81@karlmenn.is> <4883AA53-1493-498A-9016-EEE457DEF4A0@objectstyle.org> To: user@cayenne.apache.org X-Mailer: Apple Mail (2.3124) archived-at: Tue, 16 Aug 2016 11:25:31 -0000 Cool. Appreciate the bug reports! > On Aug 16, 2016, at 2:22 PM, Hugi Thordarson wrote: >=20 > Thanks Andrus :). >=20 > It works for the most part but I=E2=80=99m still running into some = problems. I think I=E2=80=99ll switch to SQL for now for the methods = where this matters. I=E2=80=99m filing JIRAs for the issues I=E2=80=99ve = encountered but FYI, this is where it fails: >=20 > Failure 1: > Wrong SQL generated for a DISTINCT count using a DB path. Example: >=20 > Running EJBQL query: > select count(distinct db:e.receipt_id) from Entry e >=20 > Generates SQL: > SELECT COUNT(DISTINCT *) AS sc0 FROM `strimillinn`.`fd_entry` t0 >=20 > Should generate SQL: > SELECT COUNT(DISTINCT receipt_id) AS sc0 FROM `strimillinn`.`fd_entry` = t0 >=20 > =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94 >=20 > Failure 2: > EJBQL fails to find joins for relationships when DB-paths are used in = the where-clause. >=20 > Running EJBQL query: > select r.entries from Receipt r where db:r.shop.name=3D'Holtagar=C3=B0ar= ' >=20 > Results in a EJBQLException with the message: > "No join configured for id r.shop" >=20 > Running the same query using a regular path (not a DB path) works = fine: > select r.entries from Receipt r where r.shop.name=3D'Holtagar=C3=B0ar' >=20 > Cheers, > - hugi >=20 >=20 >> On 16. =C3=A1g=C3=BA. 2016, at 07:26, Andrus Adamchik = wrote: >>=20 >> Looks like DB path prefix was ignored everywhere except in = conditions. E.g. here it would work, but nowhere else: >>=20 >> select p.estimatedPrice from Painting p WHERE db:p.ESTIMATED_PRICE > = 2 >>=20 >> Since expanding it to SELECT clause didn't require a parser change, = the fix was actually pretty easy. I just committed it. See = 5869e40f61e547cb33285803eede286a780cb0f3 and CAY-2102. >>=20 >> Andrus >>=20 >>> On Aug 15, 2016, at 9:53 PM, Hugi Thordarson = wrote: >>>=20 >>> I=E2=80=99m not quite getting this to work=E2=80=A6 In this case I = have a list of Receipts linked to Shops, and I want to select the shop = IDs (simplified example). If I try: >>>=20 >>> select db:r.shop_id from Receipt r >>>=20 >>> I=E2=80=99ll receive an error that =E2=80=9Cshop_id=E2=80=9D is an = invalid path component. >>>=20 >>>=20 >>>=20 >>>=20 >>>> On 15. =C3=A1g=C3=BA. 2016, at 17:18, Andrus Adamchik = wrote: >>>>=20 >>>>> One last question: Can I use db:-paths in EJBQL queries? >>>>=20 >>>> Yes, db path should be supported everywhere.=20 >>>>=20 >>>>> Particularly, I=E2=80=99m attempting to use FK-columns (that = aren=E2=80=99t exposed in the ObjEntity) in my queries, perhaps = there=E2=80=99s another way? >>>>=20 >>>>=20 >>>> If possible, use a relationship name instead of FK. E.g.=20 >>>>=20 >>>> "SELECT p FROM Painting p WHERE p.artist =3D 1" >>>>=20 >>>> but if not, db path is an option. >>>>=20 >>>> Andrus >>>>=20 >>>>=20 >>>>> On Aug 15, 2016, at 7:02 PM, Hugi Thordarson = wrote: >>>>>=20 >>>>> Thanks for this Andrus. One last question: Can I use db:-paths in = EJBQL queries? Particularly, I=E2=80=99m attempting to use FK-columns = (that aren=E2=80=99t exposed in the ObjEntity) in my queries, perhaps = there=E2=80=99s another way? >>>>>=20 >>>>> Cheers, >>>>> - hugi >>>>>=20 >>>>>=20 >>>>>=20 >>>>>> On 15. =C3=A1g=C3=BA. 2016, at 15:31, Andrus Adamchik = wrote: >>>>>>=20 >>>>>> Ah yeah, now checking the code I am starting to remember. = Arithmetic expressions are not allowed in SELECT clause, only in WHERE. = There's no real reason for it other then us initially basing EJBQL = parser on some early JPA spec that probably didn't support it. We need = to add it to the parser. For now it won't work. >>>>>>=20 >>>>>> Andrus >>>>>>=20 >>>>>>=20 >>>>>>> On Aug 15, 2016, at 5:49 PM, Hugi Thordarson = wrote: >>>>>>>=20 >>>>>>> Hi Andrus, >>>>>>>=20 >>>>>>>> On 15. =C3=A1g=C3=BA. 2016, at 06:30, Andrus Adamchik = wrote: >>>>>>>>=20 >>>>>>>> Hi Hugi, >>>>>>>>=20 >>>>>>>> Sorry for delayed reply. I swear we had the BNF for EJBQL in = the docs, but apparently we don't. Here is the closest thing to it - a = JavaCC grammar: >>>>>>>>=20 >>>>>>>> = https://github.com/apache/cayenne/blob/master/cayenne-server/src/main/jjtr= ee/org/apache/cayenne/ejbql/EJBQLParser.jjt >>>>>>>>=20 >>>>>>>> We do support simple arithmetic operations. Search for = 'arithmetic_' clauses in the .jjt. >>>>>>>=20 >>>>>>> I=E2=80=99m not as smart as you think=E2=80=94I haven=E2=80=99t = touched JavaCC grammar before, though I could figure it out but I = don=E2=80=99t see how to do this :). Can you tell me how I can do = something equivalent to =E2=80=9Cselect e.price*e.quantity from Entry = e=E2=80=9D? >>>>>>>=20 >>>>>>> Cheers, >>>>>>> - hugi >>>>>>=20 >>>>>=20 >>>>=20 >>>=20 >>=20 >=20