6.2.2 The #:what clause
The #:what clause specifies the result type of the query. The data in the #:what clause must be derived from that selected in the #:from clause.
For example, the query:
(sql (select #:from person))
has a result type of person, whereas the query:
(sql (select #:what person.name #:from person))
has a result type of string. The expression:
(find-all (sql (select #:what person.name #:from person)))
would therefore return a (listof person).
The #:what clause can be one of the following:
an entity or entity alias:
; (listof person) (find-all (sql (select #:what person #:from ; ...))) an attribute or attribute alias:
; (listof string) (find-all (sql (select #:what person.surname #:from ; ...))) an SQL expression (like those used in #:where clauses):
; (listof string) (find-all (sql (select #:what (string-append person.forenames " " person.surname) #:from ; ...))) a list of the above:
; (listof (list string string)) (find-all (sql (select #:what (person.forenames person.surname) #:from ; ...)))
If the #:what clause is omitted, Snooze infers the result type from the #:from clause:
if #:from is a single entity, the result type is the relevant persistent struct type:
; (listof person) (find-all (sql (select #:from person))) if #:from is a subquery, the result type is the same as that of the subquery:
; (listof person) (find-all (sql (select #:from (select #:from person)))) if #:from is a join, the result type is a flattened list of the result types of the join arguments:
; (listof (list employer employee)) (find-all (sql (select #:from (inner employer employee ; ...))))