adl.to-psql
Application Description Language: generate Postgres database definition.
compose-convenience-entity-field
(compose-convenience-entity-field field entity application)
(compose-convenience-entity-field field entity application table-alias)
*TODO: write docs
compose-convenience-view-from-list
(compose-convenience-view-from-list entity application top-level?)
Compose the FROM list 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.
construct-link-property
(construct-link-property entity)
Create a dummy property for a link-table referencing this entity
, in order that the field generation functions already defined may be applied to it.
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 property entity application)
(emit-convenience-entity-field property entity application table-alias)
*TODO: 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)
Emit a declaration for this authorisation group
.
emit-link-field
(emit-link-field property entity application)
Emit an appropriate link field for this property
of this entity
within this application
.
emit-link-table
(emit-link-table property e1 application emitted-link-tables)
Emit a link table for the specified property
of the entity e1
within this application
, provided that such a table has not already been emitted from the other end. The argument emitted-link-tables
contains an atom which references a set of the names of all those link tables which have already been emitted, and this is modified in the execution of this function.
emit-link-tables
(emit-link-tables entity application emitted-link-tables)
(emit-link-tables application emitted-link-tables)
Emit all required link tables for this entity
within this application
, given these emitted-link-tables
which have already been emitted.
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-referential-integrity-link
(emit-referential-integrity-link property nearside application)
Emit a referential integrity link for this property
of the entity nearside
within this application
.
emit-referential-integrity-links
(emit-referential-integrity-links entity application)
(emit-referential-integrity-links application)
Emit all appropriate referential integrity links for 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
.