norm
norm · No-ORM helper extension that generates simple CRUD functions.
Overview
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
norm is a pure SQL/PLpgSQL code generator for simple CRUD functions. Its generators inspect catalog metadata and create table-specific SECURITY DEFINER functions. Use it only in a trusted schema-migration workflow where every identifier and every generated definition is reviewed.
Core Workflow
The public generators are norm_insert(table, columns, function_name), norm_update(table, columns, filters, function_name), norm_delete(table, filters, function_name), and norm_get(tables, columns, filters, function_name). The final name argument is optional; defaults are derived from the table names.
Generated update functions use coalesce(parameter, column), so they cannot set a target column to SQL NULL. Multi-table reads infer inner joins from foreign keys, reject tables with multiple foreign keys in the supported path, and do not provide outer joins, aggregates, or arbitrary subqueries.
Security Boundary
The reviewed SQL interpolates caller-supplied table, column, and custom function names without consistently using identifier quoting. Generated SECURITY DEFINER functions also do not establish a hardened search_path. Untrusted generator input can therefore become SQL injection, object substitution, or privilege escalation.
Do not grant generator execution to application roles. Run it only as a controlled deployment step, avoid ambiguous same-named tables across schemas, inspect the resulting function definitions and owners, set a safe execution path, and revoke default privileges before exposing any generated helper.