Macro Select

Part of:

package cl-perec
( select &rest < args > )
Selects object from the model.

Syntax:

select [<options>] <select-list> <from clause> [<where-clause>] [<order-by-clause>]

<options>: (&key result-type flatp uniquep)
<select-list>: (<expr>*)
<from-clause>: (<variable-spec>*)
<variable-spec>: <symbol> | (<symbol> <type-expr>)
<where-clause>: (where <bool-expr>)
<order-by-clause>: (order-by <order-spec>*)
<order-spec>: :ascending|:descending <expr>

Semantics:

Analogous to SQL:
First the cartesian product of the set of objects specified by the FROM clause
is created. Then the product is filtered by the WHERE clause and projected
according to the SELECT-LIST. Finally the result is sorted according to the
ORDER-BY clause.

Options may modify the result:

result-type: (member 'list 'scroll)
If the value is 'scroll then the result of the query returned as an instance
of the 'scroll class. If the value is 'list the the result is a list.
Default is 'list.

flatp: generalized-boolean
If true and the result-type is 'list then result is a flattened list, i.e. the
select list expressions are appended rather than added to the result.
Default is true for one element select lists, false otherwise.

uniquep: generalized-boolean
If true then the value of the select list will not be added to the result,
when it is equal to a previously seen value.

prefetch-mode: (member :none :accessed :all)
Determines which slots filled in the cached objects returned by the query.
If :none then only the oid is filled in,
if :accessed then only the slots that are stored in accessed tables are filled in,
if :all then all slots are filled in.
Default is :accessed.

Example:

(let ((yesterday (day-before-today)))
(select ((name-of topic) message)
(from (topic topic) message)
(where (and (typep message 'message)
(eq (topic-of message) topic)
(after (date-of message) yesterday)))))