Files
relspecgo/pkg/writers/pgsql/templates/fragments.tmpl
Hein 5e1448dcdb
Some checks are pending
CI / Test (1.23) (push) Waiting to run
CI / Test (1.24) (push) Waiting to run
CI / Test (1.25) (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Build (push) Waiting to run
sql writer
2025-12-17 20:44:02 +02:00

45 lines
1.0 KiB
Cheetah

{{/* Reusable template fragments */}}
{{/* Column definition fragment */}}
{{- define "column_definition" -}}
{{.Name}} {{.Type}}
{{- if .Default}} DEFAULT {{.Default}}{{end}}
{{- if .NotNull}} NOT NULL{{end}}
{{- end -}}
{{/* Comma-separated column list */}}
{{- define "column_list" -}}
{{- range $i, $col := . -}}
{{- if $i}}, {{end}}{{$col}}
{{- end -}}
{{- end -}}
{{/* Qualified table name */}}
{{- define "qualified_table" -}}
{{.SchemaName}}.{{.TableName}}
{{- end -}}
{{/* Index method clause */}}
{{- define "index_method" -}}
{{- if .IndexType}}USING {{.IndexType}}{{end -}}
{{- end -}}
{{/* Uniqueness keyword */}}
{{- define "unique_keyword" -}}
{{- if .Unique}}UNIQUE {{end -}}
{{- end -}}
{{/* Referential action clauses */}}
{{- define "referential_actions" -}}
{{- if .OnDelete}}
ON DELETE {{.OnDelete}}
{{- end}}
{{- if .OnUpdate}}
ON UPDATE {{.OnUpdate}}
{{- end}}
{{- end -}}
{{/* Comment statement */}}
{{- define "comment_on" -}}
COMMENT ON {{.ObjectType}} {{.ObjectName}} IS {{quote .Comment}};
{{- end -}}