This section describes the tree construction procedures, most of which are still (at this time, 2005-02-24) considered experimental. You should take this as an invitation to experiment and share your observations w/ the Guile-PG maintainer so that we can refine them nicely for the 1.0 release.
Return a tree made by mapping proc over list ls, with elements separated by commas. Optional third arg parens? non-
#f
includes surrounding parentheses. The rest of the args are more lists, whose cars are passed as additional args to proc.
Return a order-by clause tree for orderings (a list). Each element of orderings has the form:
(ORDFUNC EXPR)
. If ordfunc is the symbol<
or the keyword#:ASC
, it is taken asASC
. Likewise,>
or#:DESC
is taken asDESC
.
Return a select-cols clause tree for cols (a list). Each element of cols can take one of several forms:
- title
- A symbol, a column name possibly qualified with the table name. For example,
foo.bar
means tablefoo
, columnbar
.(
title.
expr)
- title is a string to be used to name the output for the column described by prefix-style expression expr.
- expr
- A prefix-style expression. The name of the output column described by expr is usually expr's outermost function or operator.
Return a from clause tree for items (a list). Each element of items, a from-item, can take one of several forms:
- table-name
- A symbol.
(
alias.
table-name)
- A pair of symbols.
(
jtype[
jcondition]
left-from right-from)
- This is a join clause, where jtype is a keyword, one of
#:join
,#:left-join
,#:right-join
,#:full-join
; and left-from and right-from are each a single from-item to be handled recursively. If jtype is#:join
, jcondition must be omitted. Otherwise, it is one of:
#:natural
(#:using
col1 col2...)
(#:on
pexp)
Return a select/from/col combination clause tree for froms and cols (both lists). In addition to the constituent processing done by
make-SELECT/COLS-tree
andmake-FROM-tree
on cols and froms, respectively, prefix aSELECT
token. If froms is#f
, it is omitted.
Return a select tail tree for plist, a list of alternating keywords and related expressions. These subsequences are recognized:
#:from x
- Pass x to
make-FROM-tree
.#:where x
- Pass x to
make-WHERE-tree
.#:group-by x
- Pass x to
make-GROUP-BY-tree
.#:having x
- Pass x to
make-HAVING-tree
.#:order-by x
- Pass x to
make-ORDER-BY-tree
.#:limit n
#:offset n
- Arrange for the tree to include
LIMIT n
and/orOFFSET n
. n is an integer.If an expression (x or n) is
#f
, omit the associated clause completely from the returned tree.
Return a select tree of composition for cols/subs and tail.
If composition is
#t
, cols/subs is passed directly tomake-SELECT/COLS-tree
. Otherwise, it should be one of:#:union #:intersect #:except #:union-all #:intersect-all #:except-allcols/subs is a list of sublists taken as arguments to
parse+make-SELECT-tree
(applied recursively to each sublist), and finally combined by composition.tail is passed directly to
parse+make-SELECT/tail-tree
.