SQL populate templates
Table of Contents
This page is the literate source for the sql_populate facet of the
codegen template library. Each section documents one template and
holds its source in a mustache block tangled to the sibling
.mustache file consumed by generator.py. The .mustache files are
generated artefacts — edit this document, then run the tangle
(compass build --direct tangle_codegen_templates or
projects/ores.lisp/src/ores-build-codegen-templates.el directly).
Output paths and profile membership come from
facet_catalogue.org.
Summary
Thirteen reference-data INSERT templates: dataset and catalog
registration, ISO and non-ISO currencies, countries, flag SVGs,
methodologies, tags, the FPML refdata artefact/function pair, and
the batch-execute master include. None belongs to a profile — all
are invoked directly by generator.py's dataset pipeline (the
slovaris dataset and FPML reference data now owned by ores.seeder).
The sql_populate facet
The data projection: where sql_schema renders an entity's shape,
these templates render its contents — typed datasets (ISO 4217,
ISO 3166, FPML coding schemes, …) traced back to their source via
dataset rows, dependency links, catalogs and methodologies. The
recurring pattern is one INSERT block per item inside a dataset
section, each row carrying the dataset code for provenance.
Mustache incantations
Several templates predate the standard header and open with their own
{{! purpose }} comment plus an AUTO-GENERATED SQL banner — both
preserved verbatim. FPML templates branch on optional fields with
{{#field}}/{{^field}} pairs (e.g. publication_date,
description); sql_flag_populate inlines whole SVG documents via
{{generated_svg}}. Otherwise the group's standard constructs.
Archetypes
| Archetype | Description |
|---|---|
| sql_batch_execute.mustache | Master include for a dataset: \ir every generated file in dependency order ({{#model.files}}), with \echo progress markers. The original file had no trailing newline; tangling added one (render-neutral, verified). |
| sql_catalog_populate.mustache | Registers data catalogs ({{#catalogs}}: name, owner, description). |
| sql_country_populate.mustache | ISO 3166 countries from the country_currency dataset rows: code, numeric, name, official name, traced to {{countries_dataset.name}}. |
| sql_currency_populate.mustache | ISO 4217 currencies joined to their countries ({{#country_currency}}), with asset_class and lower-cased country code for flag linkage. |
| sql_non_iso_currency_populate.mustache | Supplementary currencies outside ISO 4217 (crypto, metals, funds): same row shape as the ISO template but driven by a standalone {{dataset}} with source_version provenance and flag_key asset linkage. |
| sql_dataset_populate.mustache | Registers the datasets themselves ({{#datasets}}: code, name, catalog, coding scheme, asset type, business context) — the provenance rows every other populate references. |
| sql_dataset_dependency_populate.mustache | Parent/child links between datasets ({{#dataset_dependencies}}: parent code, dependency code, role) so consumers can order loads. |
| sql_dataset_refdata.mustache | Dataset row for one FPML coding scheme ({{dataset}} with optional publication_date), emitted per scheme by the FPML import. |
| sql_flag_populate.mustache | Country flag SVGs as image rows: {{generated_svg}} inlines the document per country_currency row, keyed by lower-cased country code. |
| sql_methodology_populate.mustache | Dataset methodologies ({{#methodologies}}: name, description, steps, url) documenting how each dataset was produced. |
| sql_populate_function_refdata.mustache | PL/pgSQL function inserting an FPML entity's artefact rows into its production table, with an {{#image_linking}} variant joining image ids. Driven by the entity model (entity_plural / entity_singular). |
| sql_populate_refdata.mustache | INSERTs one FPML coding scheme's values into the entity's artefact staging table (code, optional description, dataset provenance) — the data counterpart of sql_schema_artefact_create. |
| sql_tag_populate.mustache | Classification tags (domain, subject area, name, description) per dataset. |
See also
- (Parent template group doc:
<group>_group.org.) - Codegen template library — the groups overview.
- Facet — the MASD concept these templates project.
- SQL facet — the facet's modeling reference.
- Applied MASD — the facet catalogue and codegen routes.
- facet_catalogue.org — profile → template/output mapping.