adl.to-psql

Application Description Language: generate Postgres database definition.

compose-convenience-entity-field

(compose-convenience-entity-field field entity application)
FIXME: write docs

compose-convenience-view-select-list

(compose-convenience-view-select-list entity application top-level?)
Compose the body of an SQL `SELECT` statement for a convenience view of this
`entity` within this `application`, recursively. `top-level?` should be set
only on first invocation.

compose-convenience-where-clause

(compose-convenience-where-clause entity application top-level?)
Compose an SQL `WHERE` clause for a convenience view of this
`entity` within this `application`.
TODO: does not correctly compose links at one stage down the tree.
See `lv_electors`, `lv_followuprequests` for examples of the problem.

emit-application

(emit-application application)
Emit all SQL declarations required to initialise a Postgres database for
this `application`.

emit-convenience-entity-field

(emit-convenience-entity-field field entity application)
FIXME: write docs

emit-convenience-view

(emit-convenience-view entity application)
Emit a convenience view of this `entity` of this `application` for use in generating lists,
menus, et cetera.

emit-defined-field-type

(emit-defined-field-type property application)
Generate appropriate field type and constraints for this `property`
given this `typedef`.

emit-entity-field-type

(emit-entity-field-type property application)
Emit an appropriate field type for this `property`, expected to reference an entity, in this `application`.

emit-field-type

(emit-field-type property entity application key?)
Emit an appropriate field type for this `property`, expected to belong to
this `entity` within this `application`.

emit-file-header

(emit-file-header application)
Generate an appropriate file header for the Postgres initialisation script
for this `application`.

emit-group-declaration

(emit-group-declaration group application)
Emit a declaration for this authorisation `group` within this `application`.

emit-permissions-grant

(emit-permissions-grant table-name privilege permissions)
Emit an appropriate grant of permissions on this `table-name` at this
`privilege` level given these `permissions`. `privilege` is expected
to be one of #{:SELECT :INSERT :UPDATE :DELETE}.
TODO: more thought needed here.

emit-property

(emit-property property entity application)(emit-property property entity application key?)
Emit a field declaration representing this `property` of this `entity` within this `application`.

emit-table

(emit-table entity application doc-comment)(emit-table entity application)
Emit a table declaration for this `entity` of this `application`,
documented with this `doc-comment` if specified.

field-name

(field-name property)
Return the appropriate field name for this `property`.
TODO: really belongs in `adl-support.utils`.

to-psql

(to-psql application)
Generate a complete Postgres database initialisation script for this `application`.