Bug 37018: Clarify operators
This patch clarifies the list of operators both in the validate routine
and in the swagger descrption block where we document this feature for
the end user.
JD amended patch: tidy
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: wainuiwitikapark <wainuiwitikapark@catalyst.net.nz>
(cherry picked from commit 534e7bf44a)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
This commit is contained in:
parent
05ee5d6ef6
commit
f245cf3f83
|
|
@ -512,7 +512,8 @@ sub _parse_dbic_query {
|
|||
sub _validate_operator {
|
||||
my ($operator) = @_;
|
||||
my %allowed_operators =
|
||||
map { $_ => 1 } qw(= != < > <= >= like -not_like -in -ident -bool -not_bool -or -like -not -and -regexp);
|
||||
map { $_ => 1 }
|
||||
qw(= != < > <= >= -in -ident -bool -not_bool -or like -like -not_like -between -not_between -not -and -regexp);
|
||||
Koha::Exceptions::REST::Query::InvalidOperator->throw( operator => $operator )
|
||||
unless exists $allowed_operators{$operator};
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -687,13 +687,27 @@ info:
|
|||
We can refine that with more complex matching clauses by nesting a the clause into the
|
||||
object; `{ "fieldname": { "clause": "value" } }`.
|
||||
|
||||
Available matching clauses include `>`, `<`, `>=`, `<=`, `-like`, and `-not_like`.
|
||||
Available matching clauses include `=`, `!=`, `<`, `>`, `<=`, `>=` and `-not`. We also support `-like`
|
||||
and `-not_like` string comparisons with `%` used to denote wildcards, thus you can pass
|
||||
`{ "fieldname": { "-like": "value%" } }` to do a 'starts with' string match for example.
|
||||
|
||||
We can filter on multiple fields by adding them to the JSON respresentation. Adding at `HASH`
|
||||
level will result in an "AND" query, whilst combinding them in an `ARRAY` will result in an
|
||||
"OR" query: `{ "field1": "value2", "field2": "value2" }` will filter the response to only those
|
||||
results with both field1 containing value2 AND field2 containing value2 for example.
|
||||
|
||||
There is a collection of special operators also available to you, including:
|
||||
|
||||
* `-in` - Expects an array of values to perform an OR match against
|
||||
* `-not_in` - Expects an array of values to perform a NOR match against
|
||||
* `-between` - Expects two values which the value of the field is expected to fall between
|
||||
* `-not_between` - Expects two values which the value of the field is expected to fall outside of
|
||||
* `-ident` - Expects a second field name to match the two field values against
|
||||
* `-regexp` - Expects a perl compatible regular expression for which the value should match
|
||||
|
||||
Logic and nesting is also supported and you may use `-and` and `-or` to change the logic of an ARRAY
|
||||
or HASH as described above.
|
||||
|
||||
Additionally, if you are requesting related data be embedded into the response one can query
|
||||
on the related data using dot notation in the field names.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue