1
1
== Expression Syntax
2
2
3
3
Expressions passed via an `exp` control parameter or inside a JSON `include` are conditions evaluated in the context of
4
- the root request entity (in the former case), or a nested entity (in the latter case). We've already discussed
4
+ the root request entity (in the former case), or a nested entity (in the latter case). We've already shown
5
5
the URL parameter structure for `exp` (e.g. how to pass parameters). Here we will focus on the syntax of the expression
6
6
itself.
7
7
8
- NOTE: The expression syntax presented here is a part of the Agrest protocol. Some Agrest backends may not be able to
9
- support every single expression described here, but most should work with a reasonable subset. And the default Java
10
- server shipped with Agrest (that works on top of relational databases) supports the syntax in its entirety.
8
+ NOTE: The syntax presented here is a part of the Agrest protocol. Though some Agrest backends may not be able to
9
+ support every single expression described here, but most should work with a reasonable subset. The Java server framework
10
+ shipped by the Agrest project supports the syntax in its entirety.
11
11
12
12
=== Literals
13
13
@@ -41,7 +41,7 @@ A variety of number literals are supported - positive / negative, whole / decima
41
41
// double
42
42
2.1
43
43
44
- // big decimal
44
+ // big decimal (arbitrary size and precision)
45
45
2.1001234065B
46
46
47
47
// TODO: hex types, etc.
@@ -54,14 +54,14 @@ String literals contain arbitrary sequences of characters, and are enclosed in e
54
54
'abc'
55
55
"abc"
56
56
57
- // if quotes are present in strings , either use non-conflicting quote symbols,
57
+ // if quotes are present in a string , either use non-conflicting quote symbols,
58
58
// or escape them explicitly
59
59
'a"c'
60
60
"a'c"
61
61
"a\"c"
62
62
----
63
63
64
- Date / time components are regular quoted strings that follow ISO 8601 format:
64
+ Date / time components are just strings that follow ISO 8601 format:
65
65
[source]
66
66
----
67
67
"2023-09-11"
@@ -87,16 +87,23 @@ books
87
87
// Dot-separated path spanning multiple entities
88
88
books.id
89
89
books.library.name
90
+ ----
91
+
92
+ NOTE: Paths are used not only in expressions, but also in a variety of other control parameters (`sort`, `include`,
93
+ `exclude`, `mapBy`)
94
+
95
+ There are a few advanced features that allow to specify special behavior of the relationship path components:
90
96
91
- // Adding "+" to a relationship name anywhere in the path indicates "optional" semantics.
97
+ [source]
98
+ ----
99
+ // "Optional" semantics
100
+
101
+ // Adding "+" to a relationship anywhere in the path indicates optional" semantics.
92
102
// This is a hint to the server evaluating the expression. E.g. if the expression is
93
103
// translated to SQL, LEFT JOIN will be used for optional expressions
94
104
books+.library.name
95
105
----
96
106
97
- NOTE: Paths are used not only in expressions, but also in a variety of other control parameters (`sort`, `include`,
98
- `exclude`, `mapBy`)
99
-
100
107
=== Parameters
101
108
102
109
Parameters are placeholders in expressions that are replaced with scalar values when the expression is
0 commit comments