Filtering fields

Fields can be filtered by adding a filter to the field name.

  • Filters are case insensitiv.
  • Arguments are separated by whitespace.
  • Strings and enum arguments are enclosed with single quotes.
  • Boolean arguments are expressed with numbers 0 and 1.

To use a field only for filtering, but not for selection, hide it with a dot: .age gt 50, .book_reviewed eq 1

Example

id, book_published eq 1, .age gt 50

is typically translated into (using canonical aliases)

SELECT user.id, user_book.id, user_book.published FROM User user JOIN Book user_book ON (user.book_id = user_book.id) WHERE user_book.published = 1 AND user.age > 50

Filter operations

Toql Operation Example SQL
eq equal age eq 50 age = 50
eqn equal null age eqn age IS NULL
ne not equal name ne 'foo' name <> 'foo'
nen not equal null age nen age IS NOT NULL
gt greater than age gt 16 age > 16com
ge greater than or equal age ge 16 age >= 16
lt less than age lt 16 age < 16
le less than or equal age le 16 age <= 16
bw between age bw 16 20 age BETWEEN 16 AND 20
in includes name in 'Peter' 'Susan' name in ('Peter, 'Susan')
out excludes age out 1 2 3 name not in (1, 2, 3)
fn custom function search fn ma 'arg1' depends on implementation

Custom functions

Custom functions are applied through the FN filter. They must be handled by a Field Handler. See API for details.

Joining filters

A field can be filtered multiple times by adding multiple the filter expressions in the query.

To build complex filter expressions join filters by comma to express logical AND or semicolon for logical OR. Keep in mind that logical AND has higher precendence than logical OR.

Use parens if required:

age eq 12, animal eq 'chicken'; animal eq 'cow

is the same as

(age eq 12, animal eq 'chicken'); animal eq 'cow

but different than

age eq 12, (animal eq 'chicken'; animal eq 'cow)

Use the dot notation if you only want to filter a field without selecting it:

age eq 12, .animal eq 'chicken'; .animal eq 'cow'

Argument types

Toql onyl knows integers, floats and strings. Use the following table to express more types:

Type Toql Example Remark
bool admin eq 1 0, 1
integer limit bw -12 5
float price le 0.5e2
string name in 'peter' Single quotes
date subscribeUntil le '2050-12-31'SQL format
time start ge '08:30:00' SQL format
date time finishedAt ge '2005-12-31 08:30:00' SQL format