Selecting fields

Fields are selected if they are mentioned in the query.

  • Names without underscore represent typically columns or expressions from the table the query is run against. id, name, fullName, emailAddress

  • Fields with underscores are called fields with a path. They are mapped to a joined or a merged dependency. For a join relationship, the join will be added to the SQL statement if the field is selected. For a merge relationship a second SQL query must be run to query and merge the dependency. book_id, book_title, book_createdBy_id

  • To use a field only for filtering, but not for selection hide it with a dot. .age, .book_id

Example

id, book_id, .age eq 50

is translated into (SQL Mapper must be told how to join)

SELECT a.id, b.id, null FROM User a JOIN Book b ON (a.book_id = b.id) WHERE a.age > 50

Wildcards

There are two wildcards to select multiple fields. They can neither be filtered nor ordered.

  • ** selects all mapped fields (top level and dependencies). Useful for development.

  • * selects all fields from the top level.

  • path_* selects all fields from path.

Fields can be excluded from the wildcard by setting them to ignore wildcard.

Example

id, age, book_id, .age eq 50

can be expressed as

*, book_*, .age eq 50

can be expressed as

**, .age eq 50

and is translation into

SELECT id, book_id, age FROM FROM User a JOIN Book b ON (a.book_id = b.id) WHERE a.age > 50

Note that the age field is selected with **.

Roles

Fields can require roles from the query. This is the permission system from Toql. An error is raised, if a query selects a field that it's not allowed to. However if the query selects with a wildcard, the field will just be ignored.