From 3d050f81064830fe7888e2f37fe973f23984ef4d Mon Sep 17 00:00:00 2001
From: Lukas Eder
Date: Thu, 15 Aug 2013 13:34:41 +0200
Subject: [PATCH] [#2660] Add some documentation about jOOQ not supporting
operator precedence
---
.../src/main/resources/manual-3.2.xml | 33 ++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/jOOQ-website/src/main/resources/manual-3.2.xml b/jOOQ-website/src/main/resources/manual-3.2.xml
index 35acc54820..93c4092eac 100644
--- a/jOOQ-website/src/main/resources/manual-3.2.xml
+++ b/jOOQ-website/src/main/resources/manual-3.2.xml
@@ -3975,7 +3975,15 @@ Field field2 = val("1").coerce(Integer.class);]]>
You can write something like this in jOOQ:
-create.select(val(1).add(2).mul(val(5).sub(3)).div(2).mod(10);
+create.select(val(1).add(2).mul(val(5).sub(3)).div(2).mod(10));
+
+ Operator precedence
+
+ jOOQ does not know any operator precedence (see also ). All operations are evaluated from left to right, as with any object-oriented API. The two following expressions are the same:
+
+
+ val(1).add(2) .mul(val(5).sub(3)) .div(2) .mod(10);
+(((val(1).add(2)).mul(val(5).sub(3))).div(2)).mod(10);
Datetime arithmetic expressions
@@ -5076,6 +5084,29 @@ BOOK.TITLE.notEqualIgnoreCase("animal farm")]]>
+
+
+ Boolean operator precedence
+
+
+ As previously mentioned in the manual's section about , jOOQ does not implement operator precedence. All operators are evaluated from left to right, as expected in an object-oriented API. This is important to understand when combining , such as AND, OR, and NOT. The following expressions are equivalent:
+
+
+
+ A.and(B) .or(C) .and(D) .or(E)
+(((A.and(B)).or(C)).and(D)).or(E)
+
+
+
+ In SQL, the two expressions wouldn't be the same, as SQL natively knows operator precedence.
+
+
+
+ A AND B OR C AND D OR E -- Precedence is applied
+(((A AND B) OR C) AND D) OR E -- Precedence is overridden
+
+
+
Comparison predicate (degree > 1)