You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/11/18 17:27:45 UTC

[24/50] usergrid git commit: Add a note about precedence to the operators page.

Add a note about precedence to the operators page.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/27de65ce
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/27de65ce
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/27de65ce

Branch: refs/heads/USERGRID-872
Commit: 27de65cecd0da42d30d200cd4a04d3f5047ba2b5
Parents: bab89fe
Author: Dave Johnson <sn...@apache.org>
Authored: Fri Nov 13 09:55:04 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri Nov 13 09:55:04 2015 -0500

----------------------------------------------------------------------
 docs/data-queries/operators-and-types.md | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/27de65ce/docs/data-queries/operators-and-types.md
----------------------------------------------------------------------
diff --git a/docs/data-queries/operators-and-types.md b/docs/data-queries/operators-and-types.md
index bb42107..8c0bb6a 100644
--- a/docs/data-queries/operators-and-types.md
+++ b/docs/data-queries/operators-and-types.md
@@ -41,6 +41,11 @@ The following operators and data types are supported by the SQL-like query langu
         <td>select * where quantity < '4000' and not quantity = '2000'</td>
     </tr>
     <tr>
+        <td>contains</td>
+        <td>Narrow by contained text</td>
+        <td>select * where title contains 'tale'</td>
+    </tr>
+    <tr>
         <td>and</td>
         <td>Union of results</td>
         <td>select * where quantity > '1000' and quantity < '4000'</td>
@@ -50,14 +55,24 @@ The following operators and data types are supported by the SQL-like query langu
         <td>Intersection of results</td>
         <td>select * where quantity = '1000' or quantity = '4000'</td>
     </tr>
-    <tr>
-        <td>contains</td>
-        <td>Narrow by contained text</td>
-        <td>select * where title contains 'tale'</td>
-    </tr>
 </table>
 
 
+### Precedence 
+
+The operators at the bottom of the above table are the ones with lower precedence. 
+When a query is evaluated the comparison operators (=, > , <, <= and >=) will be evaluated first.
+And next "not", "contains" and "or" will be evaluated and in that order.
+
+Though they are not shown above, parentheses are allowed and may be used to group query expressions.
+
+For example, given our rules of precedence, these two queries are equivalent:
+
+    select * where age > 6 or size = 'large' and color = 'tabby'
+    
+    select * where (age > 6 or size = 'large') and color = 'tabby'
+
+
 ## Data types
 
 As you develop queries, remember that entity properties each conform to a particular data type. For example, in the default entity User, the name property is stored as a string, the created date as a long, and metadata is stored as a JSON object. Your queries must be data type-aware to ensure that query results are as you expect them to be.