Add support for Postgres Functions
- Dominant language
- JavaScript
- Stars
- 3.7k
- Forks
- 233
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 4
Description
### Enhancement
Add support to generate `CREATE OR REPLACE FUNCTION` sql scripts using dbml markdown.
### Syntax
```
Function increment {
schema public
returns integer
args [len_from: integer, len_from: integer]
body `
DECLARE
film_count INTEGER;
BEGIN
SELECT COUNT(*)
INTO film_count
FROM film
WHERE length BETWEEN len_from AND len_to;
RETURN film_count;
END;
`
language plpgsql
behavior volatile
security invoker
}
```
`schema` defaults to public. Can be specified inline with the function name such as `Function public.increment { ... }`
`returns` accepts any valid return type (see list below).
`args` accepts a list of arguments with declared types. Any return type is valid, excluding `void`, `record`, and `trigger`.
`body` accepts an expression or a multi-line expression.
`language` defaults to `plpgsql`. Can be `sql`, `c`, or `internal`.
`behavior` defaults to `volatile`. Can be `immutable` or `stable`.
`security` defaults to `invoker`. Can be `definer`.
Return types:
- `void`
- `record`
- `trigger`
- `integer`
- `bool`
- `bytea`
- `date`
- `double_precision`
- `float4`
- `float8`
- `int2`
- `int4`
- `int8`
- `json`
- `jsonb`
- `numeric`
- `text`
- `time`
- `timestamp`
- `timestamptz`
- `timetz`
- `uuid`
- `varchar`
- `vector`
### Gaps
Does not implement configuration parameters.
Contributor guide
Assessment
This issue has not been assessed yet.