Documentation ¶
Index ¶
- Variables
- func DbStruct(name string) *dbStruct
- func GenerateDtos(writer io.Writer, def *Interface)
- func GenerateImplementation(writer io.Writer, def *Interface)
- func GenerateIntegrationTests(writer io.Writer, def *Interface)
- func GenerateInterface(writer io.Writer, def *Interface)
- func GenerateUnitTests(writer io.Writer, def *Interface)
- func GenerateValidations(writer io.Writer, def *Interface)
- func IsNil(val any) bool
- func KindOfPointer(kind string) string
- func KindOfSlice(kind string) string
- func KindOfT[T any]() string
- func KindOfTPointer[T any]() string
- func KindOfTSlice[T any]() string
- func PlainStruct(name string) *plainStruct
- func QueryStruct(name string) *queryStruct
- func WriteCodeToFile(buffer *bytes.Buffer, fileName string)
- type DescriptionMappingKind
- type Field
- func (f *Field) DtoDecl() string
- func (f *Field) DtoKind() string
- func (f *Field) HasAnyValidationInSubtree() bool
- func (f *Field) IsPointer() bool
- func (f *Field) IsRoot() bool
- func (f *Field) IsSlice() bool
- func (f *Field) IsStruct() bool
- func (f *Field) KindNoPtr() string
- func (f *Field) KindNoSlice() string
- func (f *Field) Path() string
- func (f *Field) PathWithRoot() string
- func (f *Field) ShouldBeInDto() bool
- func (f *Field) TagsPrintable() string
- type FieldTransformer
- type IdentifierTransformer
- func (v *IdentifierTransformer) DoubleQuotes() *IdentifierTransformer
- func (v *IdentifierTransformer) Equals() *IdentifierTransformer
- func (v *IdentifierTransformer) NoEquals() *IdentifierTransformer
- func (v *IdentifierTransformer) Required() *IdentifierTransformer
- func (v *IdentifierTransformer) SQL(sqlPrefix string) *IdentifierTransformer
- func (v *IdentifierTransformer) SingleQuotes() *IdentifierTransformer
- func (v *IdentifierTransformer) Transform(f *Field) *Field
- type Interface
- func (i *Interface) AlterOperation(doc string, queryStruct *queryStruct) *Interface
- func (i *Interface) CreateOperation(doc string, queryStruct *queryStruct, helperStructs ...IntoField) *Interface
- func (i *Interface) CustomOperation(kind string, doc string, queryStruct *queryStruct) *Interface
- func (i *Interface) DescribeOperation(describeKind DescriptionMappingKind, doc string, dbRepresentation *dbStruct, ...) *Interface
- func (i *Interface) DropOperation(doc string, queryStruct *queryStruct) *Interface
- func (i *Interface) NameLowerCased() string
- func (i *Interface) ShowByIdOperation() *Interface
- func (i *Interface) ShowOperation(doc string, dbRepresentation *dbStruct, resourceRepresentation *plainStruct, ...) *Interface
- type IntoField
- type KeywordTransformer
- func (v *KeywordTransformer) DoubleQuotes() *KeywordTransformer
- func (v *KeywordTransformer) NoQuotes() *KeywordTransformer
- func (v *KeywordTransformer) Required() *KeywordTransformer
- func (v *KeywordTransformer) SQL(sqlPrefix string) *KeywordTransformer
- func (v *KeywordTransformer) SingleQuotes() *KeywordTransformer
- func (v *KeywordTransformer) Transform(f *Field) *Field
- type ListTransformer
- func (v *ListTransformer) NoEquals() *ListTransformer
- func (v *ListTransformer) NoParentheses() *ListTransformer
- func (v *ListTransformer) Parentheses() *ListTransformer
- func (v *ListTransformer) Required() *ListTransformer
- func (v *ListTransformer) SQL(sqlPrefix string) *ListTransformer
- func (v *ListTransformer) Transform(f *Field) *Field
- type Mapping
- type Operation
- type OperationKind
- type ParameterTransformer
- func (v *ParameterTransformer) ArrowEquals() *ParameterTransformer
- func (v *ParameterTransformer) DoubleQuotes() *ParameterTransformer
- func (v *ParameterTransformer) NoEquals() *ParameterTransformer
- func (v *ParameterTransformer) NoParentheses() *ParameterTransformer
- func (v *ParameterTransformer) NoQuotes() *ParameterTransformer
- func (v *ParameterTransformer) Parentheses() *ParameterTransformer
- func (v *ParameterTransformer) Required() *ParameterTransformer
- func (v *ParameterTransformer) SQL(sqlPrefix string) *ParameterTransformer
- func (v *ParameterTransformer) SingleQuotes() *ParameterTransformer
- func (v *ParameterTransformer) Transform(f *Field) *Field
- type TagBuilder
- func (v *TagBuilder) Build() map[string][]string
- func (v *TagBuilder) DB(db ...string) *TagBuilder
- func (v *TagBuilder) DDL(ddl ...string) *TagBuilder
- func (v *TagBuilder) Identifier() *TagBuilder
- func (v *TagBuilder) Keyword() *TagBuilder
- func (v *TagBuilder) List() *TagBuilder
- func (v *TagBuilder) NoEquals() *TagBuilder
- func (v *TagBuilder) NoParentheses() *TagBuilder
- func (v *TagBuilder) Parameter() *TagBuilder
- func (v *TagBuilder) Parentheses() *TagBuilder
- func (v *TagBuilder) SQL(sql ...string) *TagBuilder
- func (v *TagBuilder) SingleQuotes() *TagBuilder
- func (v *TagBuilder) Static() *TagBuilder
- type Validation
- type ValidationType
Constants ¶
This section is empty.
Variables ¶
var DtoDeclTemplate, _ = template.New("dtoTemplate").Parse(`
type {{ .DtoDecl }} struct {
{{- range .Fields }}
{{- if .ShouldBeInDto }}
{{ .Name }} {{ .DtoKind }} {{ if .Required }}// required{{ end }}
{{- end }}
{{- end }}
}
`)
var DtoTemplate, _ = template.New("dtoTemplate").Parse(`
//go:generate go run ./dto-builder-generator/main.go
var (
{{- range .Operations }}
{{- if .OptsField }}
_ optionsProvider[{{ .OptsField.KindNoPtr }}] = new({{ .OptsField.DtoDecl }})
{{- end }}
{{- end }}
)
`)
var ImplementationTemplate, _ = template.New("implementationTemplate").
Funcs(template.FuncMap{
"deref": func(p *DescriptionMappingKind) string { return string(*p) },
}).
Parse(`
{{ define "MAPPING" -}}
&{{ .KindNoPtr }}{
{{- range .Fields }}
{{- if .ShouldBeInDto }}
{{ if .IsStruct }}{{ else }}{{ .Name }}: r{{ .Path }},{{ end -}}
{{- end -}}
{{- end }}
}
{{- range .Fields }}
{{- if .ShouldBeInDto }}
{{- if .IsStruct }}
if r{{ .Path }} != nil {
{{- if not .IsSlice }}
opts{{ .Path }} = {{ template "MAPPING" . -}}
{{- else }}
s := make({{ .Kind }}, len(r{{ .Path }}))
for i, v := range r{{ .Path }} {
s[i] = {{ .KindNoSlice }}{
{{- range .Fields }}
{{ .Name }}: v.{{ .Name }},
{{- end }}
}
}
opts{{ .Path }} = s
{{ end -}}
}
{{- end -}}
{{ end -}}
{{ end }}
{{ end }}
{{ define "MAPPING_FUNC" }}
func (r {{ .From.Name }}) {{ .MappingFuncName }}() *{{ .To.KindNoPtr }} {
// TODO: Mapping
return &{{ .To.KindNoPtr }}{}
}
{{ end }}
import (
"context"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections"
)
{{ $impl := .NameLowerCased }}
var _ {{ .Name }} = (*{{ $impl }})(nil)
type {{ $impl }} struct {
client *Client
}
{{ range .Operations }}
{{ if and (eq .Name "Show") .ShowMapping }}
func (v *{{ $impl }}) Show(ctx context.Context, request *{{ .OptsField.DtoDecl }}) ([]{{ .ShowMapping.To.Name }}, error) {
opts := request.toOpts()
dbRows, err := validateAndQuery[{{ .ShowMapping.From.Name }}](v.client, ctx, opts)
if err != nil {
return nil, err
}
resultList := convertRows[{{ .ShowMapping.From.Name }}, {{ .ShowMapping.To.Name }}](dbRows)
return resultList, nil
}
{{ else if eq .Name "ShowByID" }}
func (v *{{ $impl }}) ShowByID(ctx context.Context, id {{ .ObjectInterface.IdentifierKind }}) (*{{ .ObjectInterface.NameSingular }}, error) {
// TODO: adjust request if e.g. LIKE is supported for the resource
{{ $impl }}, err := v.Show(ctx, NewShow{{ .ObjectInterface.NameSingular }}Request())
if err != nil {
return nil, err
}
return collections.FindOne({{ $impl }}, func(r {{ .ObjectInterface.NameSingular }}) bool { return r.Name == id.Name() })
}
{{ else if and (eq .Name "Describe") .DescribeMapping }}
{{ if .DescribeKind }}
{{ if eq (deref .DescribeKind) "single_value" }}
func (v *{{ $impl }}) Describe(ctx context.Context, id {{ .ObjectInterface.IdentifierKind }}) (*{{ .DescribeMapping.To.Name }}, error) {
opts := &{{ .OptsField.Name }}{
name: id,
}
result, err := validateAndQueryOne[{{ .DescribeMapping.From.Name }}](v.client, ctx, opts)
if err != nil {
return nil, err
}
return result.convert(), nil
}
{{ else if eq (deref .DescribeKind) "slice" }}
func (v *{{ $impl }}) Describe(ctx context.Context, id {{ .ObjectInterface.IdentifierKind }}) ([]{{ .DescribeMapping.To.Name }}, error) {
opts := &{{ .OptsField.Name }}{
name: id,
}
rows, err := validateAndQuery[{{ .DescribeMapping.From.Name}}](v.client, ctx, opts)
if err != nil {
return nil, err
}
return convertRows[{{ .DescribeMapping.From.Name }}, {{ .DescribeMapping.To.Name }}](rows), nil
}
{{ end }}
{{ end }}
{{ else }}
func (v *{{ $impl }}) {{ .Name }}(ctx context.Context, request *{{ .OptsField.DtoDecl }}) error {
opts := request.toOpts()
return validateAndExec(v.client, ctx, opts)
}
{{ end }}
{{ end }}
{{ range .Operations }}
{{- if .OptsField }}
func (r *{{ .OptsField.DtoDecl }}) toOpts() *{{ .OptsField.KindNoPtr }} {
opts := {{ template "MAPPING" .OptsField -}}
return opts
}
{{ if .ShowMapping }}
{{ template "MAPPING_FUNC" .ShowMapping }}
{{ end }}
{{ if .DescribeMapping }}
{{ template "MAPPING_FUNC" .DescribeMapping }}
{{ end }}
{{- end}}
{{ end }}
`)
var IntegrationTestsTemplate, _ = template.New("integrationTestsTemplate").Parse(`
import "testing"
func TestInt_{{ .Name }}(t *testing.T) {
// TODO: prepare common resources
{{ range .Operations }}
t.Run("{{ .Name }}", func(t *testing.T) {
// TODO: fill me
})
{{ end -}}
}
`)
var InterfaceTemplate, _ = template.New("interfaceTemplate").
Funcs(template.FuncMap{
"deref": func(p *DescriptionMappingKind) string { return string(*p) },
}).
Parse(`
import "context"
type {{ .Name }} interface {
{{- range .Operations }}
{{- if and (eq .Name "Show") .ShowMapping }}
{{ .Name }}(ctx context.Context, request *{{ .OptsField.DtoDecl }}) ([]{{ .ShowMapping.To.Name }}, error)
{{- else if eq .Name "ShowByID" }}
{{ .Name }}(ctx context.Context, id {{ .ObjectInterface.IdentifierKind }}) (*{{ .ObjectInterface.NameSingular }}, error)
{{- else if and (eq .Name "Describe") .DescribeMapping }}
{{- if .DescribeKind }}
{{- if eq (deref .DescribeKind) "single_value" }}
{{ .Name }}(ctx context.Context, id {{ .ObjectInterface.IdentifierKind }}) (*{{ .DescribeMapping.To.Name }}, error)
{{- else if eq (deref .DescribeKind) "slice" }}
{{ .Name }}(ctx context.Context, id {{ .ObjectInterface.IdentifierKind }}) ([]{{ .DescribeMapping.To.Name }}, error)
{{- end }}
{{- end }}
{{- else }}
{{ .Name }}(ctx context.Context, request *{{ .OptsField.DtoDecl }}) error
{{- end -}}
{{ end }}
}
`)
var OptionsTemplate, _ = template.New("optionsTemplate").Parse(`
// {{ .OptsField.KindNoPtr }} is based on {{ .Doc }}.
type {{ .OptsField.KindNoPtr }} struct {
{{- range .OptsField.Fields }}
{{ .Name }} {{ .Kind }} {{ .TagsPrintable }}
{{- end }}
}
`)
var PackageTemplate, _ = template.New("packageTemplate").Parse(`
package {{ . }}
`)
var StructTemplate, _ = template.New("structTemplate").Parse(`
type {{ .KindNoPtr }} struct {
{{- range .Fields }}
{{ .Name }} {{ .Kind }} {{ .TagsPrintable }}
{{- end }}
}
`)
TODO: merge with template above? (requires moving Doc to field)
var TestFuncTemplate, _ = template.New("testFuncTemplate").Parse(`
{{ define "VALIDATION_TEST" }}
{{ $field := . }}
{{- range .Validations }}
t.Run("{{ .TodoComment $field }}", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsInvalidJoinedErrors(t, opts, {{ .ReturnedError $field }})
})
{{ end -}}
{{ end }}
{{ define "VALIDATIONS" }}
{{- template "VALIDATION_TEST" . -}}
{{ range .Fields }}
{{- if .HasAnyValidationInSubtree }}
{{- template "VALIDATIONS" . -}}
{{ end -}}
{{- end -}}
{{ end }}
import "testing"
{{ range .Operations }}
{{- if .OptsField }}
func Test{{ .ObjectInterface.Name }}_{{ .Name }}(t *testing.T) {
id := Random{{ .ObjectInterface.IdentifierKind }}()
// Minimal valid {{ .OptsField.KindNoPtr }}
defaultOpts := func() *{{ .OptsField.KindNoPtr }} {
return &{{ .OptsField.KindNoPtr }}{
name: id,
}
}
t.Run("validation: nil options", func(t *testing.T) {
var opts *{{ .OptsField.KindNoPtr }} = nil
assertOptsInvalidJoinedErrors(t, opts, ErrNilOptions)
})
{{- template "VALIDATIONS" .OptsField }}
t.Run("basic", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsValidAndSQLEquals(t, opts, "TODO: fill me")
})
t.Run("all options", func(t *testing.T) {
opts := defaultOpts()
// TODO: fill me
assertOptsValidAndSQLEquals(t, opts, "TODO: fill me")
})
}
{{- end }}
{{ end }}
`)
var ValidationsImplTemplate, _ = template.New("validationsImplTemplate").Parse(`
{{ define "VALIDATIONS" }}
{{- $field := . -}}
{{- range .Validations }}
if {{ .Condition $field }} {
errs = append(errs, {{ .ReturnedError $field }})
}
{{- end -}}
{{- range .Fields }}
{{- if .HasAnyValidationInSubtree }}
if valueSet(opts{{ .Path }}) {
{{- template "VALIDATIONS" . }}
}
{{- end -}}
{{- end -}}
{{ end }}
import "errors"
var (
{{- range .Operations }}
{{- if .OptsField }}
_ validatable = new({{ .OptsField.KindNoPtr }})
{{- end }}
{{- end }}
)
{{ range .Operations }}
{{- if .OptsField }}
func (opts *{{ .OptsField.KindNoPtr }}) validate() error {
if opts == nil {
return errors.Join(ErrNilOptions)
}
var errs []error
{{- template "VALIDATIONS" .OptsField }}
return errors.Join(errs...)
}
{{- end }}
{{ end }}
`)
Functions ¶
func GenerateDtos ¶
func GenerateImplementation ¶
func GenerateInterface ¶
func GenerateUnitTests ¶
func GenerateValidations ¶
func IsNil ¶ added in v0.72.0
IsNil is used for special cases where x != nil might not work (e.g. passing nil instead of interface implementation)
func KindOfPointer ¶ added in v0.72.0
func KindOfSlice ¶ added in v0.72.0
func KindOfTPointer ¶ added in v0.72.0
func KindOfTSlice ¶ added in v0.72.0
func PlainStruct ¶ added in v0.72.0
func PlainStruct(name string) *plainStruct
func QueryStruct ¶ added in v0.72.0
func QueryStruct(name string) *queryStruct
func WriteCodeToFile ¶
Types ¶
type DescriptionMappingKind ¶ added in v0.72.0
type DescriptionMappingKind string
const ( DescriptionMappingKindSingleValue DescriptionMappingKind = "single_value" DescriptionMappingKindSlice DescriptionMappingKind = "slice" )
type Field ¶
type Field struct { // Parent allows to traverse fields hierarchy more easily, nil for root Parent *Field // Fields defines children, use for struct fields Fields []*Field // Validations defines validations on given field level (e.g. oneOf for children) Validations []*Validation // Name is how field is called in parent struct Name string // Kind is fields type (e.g. string, *bool) Kind string // Tags should contain ddl and sql tags used for SQL generation Tags map[string][]string // Required is used to mark fields which are essential (it's used e.g. for DTO builders generation) Required bool }
Field defines properties of a single field or struct (by defining Fields)
func NewField ¶
func NewField(name string, kind string, tagBuilder *TagBuilder, transformer FieldTransformer) *Field
func (*Field) DtoDecl ¶
DtoDecl returns how struct should be declared in generated DTO (e.g. definition is without a pointer)
func (*Field) DtoKind ¶
DtoKind returns what should be fields kind in generated DTO, because it may differ from Kind
func (*Field) HasAnyValidationInSubtree ¶
HasAnyValidationInSubtree checks if any validations are present from current field level downwards
func (*Field) IsRoot ¶
IsRoot checks if field is at the top of field hierarchy, basically it is true for Option structs
func (*Field) KindNoSlice ¶ added in v0.72.0
KindNoSlice return field's Kind but without array
func (*Field) Path ¶
Path returns the way through the tree to the top, with dot separator (e.g. .SomeField.SomeChild)
func (*Field) PathWithRoot ¶ added in v0.75.0
PathWithRoot returns the way through the tree to the top, with dot separator and root included (e.g. Struct.SomeField.SomeChild)
func (*Field) ShouldBeInDto ¶
ShouldBeInDto checks if field is not some static SQL field which should not be interacted with by SDK user TODO: this is a very naive implementation, consider fixing it with DSL builder connection
func (*Field) TagsPrintable ¶
TagsPrintable defines how tags are printed in options structs, it ensures the same order of tags for every field
type FieldTransformer ¶ added in v0.72.0
type IdentifierTransformer ¶ added in v0.72.0
type IdentifierTransformer struct {
// contains filtered or unexported fields
}
func IdentifierOptions ¶ added in v0.72.0
func IdentifierOptions() *IdentifierTransformer
func (*IdentifierTransformer) DoubleQuotes ¶ added in v0.72.0
func (v *IdentifierTransformer) DoubleQuotes() *IdentifierTransformer
func (*IdentifierTransformer) Equals ¶ added in v0.73.0
func (v *IdentifierTransformer) Equals() *IdentifierTransformer
func (*IdentifierTransformer) NoEquals ¶ added in v0.73.0
func (v *IdentifierTransformer) NoEquals() *IdentifierTransformer
func (*IdentifierTransformer) Required ¶ added in v0.72.0
func (v *IdentifierTransformer) Required() *IdentifierTransformer
func (*IdentifierTransformer) SQL ¶ added in v0.72.0
func (v *IdentifierTransformer) SQL(sqlPrefix string) *IdentifierTransformer
func (*IdentifierTransformer) SingleQuotes ¶ added in v0.72.0
func (v *IdentifierTransformer) SingleQuotes() *IdentifierTransformer
func (*IdentifierTransformer) Transform ¶ added in v0.72.0
func (v *IdentifierTransformer) Transform(f *Field) *Field
type Interface ¶
type Interface struct { // Name is the interface's name, e.g. "DatabaseRoles" Name string // NameSingular is the prefix/suffix which can be used to create other structs and methods, e.g. "DatabaseRole" NameSingular string // Operations contains all operations for given interface Operations []*Operation // IdentifierKind keeps identifier of the underlying object (e.g. DatabaseObjectIdentifier) IdentifierKind string }
Interface groups operations for particular object or objects family (e.g. DATABASE ROLE)
func NewInterface ¶
func (*Interface) AlterOperation ¶ added in v0.72.0
func (*Interface) CreateOperation ¶ added in v0.72.0
func (*Interface) CustomOperation ¶ added in v0.73.0
func (*Interface) DescribeOperation ¶ added in v0.72.0
func (i *Interface) DescribeOperation(describeKind DescriptionMappingKind, doc string, dbRepresentation *dbStruct, resourceRepresentation *plainStruct, queryStruct *queryStruct) *Interface
func (*Interface) DropOperation ¶ added in v0.72.0
func (*Interface) NameLowerCased ¶
NameLowerCased returns interface name starting with a lower case letter
func (*Interface) ShowByIdOperation ¶ added in v0.73.0
func (*Interface) ShowOperation ¶ added in v0.72.0
type KeywordTransformer ¶ added in v0.72.0
type KeywordTransformer struct {
// contains filtered or unexported fields
}
func KeywordOptions ¶ added in v0.72.0
func KeywordOptions() *KeywordTransformer
func (*KeywordTransformer) DoubleQuotes ¶ added in v0.72.0
func (v *KeywordTransformer) DoubleQuotes() *KeywordTransformer
func (*KeywordTransformer) NoQuotes ¶ added in v0.73.0
func (v *KeywordTransformer) NoQuotes() *KeywordTransformer
func (*KeywordTransformer) Required ¶ added in v0.72.0
func (v *KeywordTransformer) Required() *KeywordTransformer
func (*KeywordTransformer) SQL ¶ added in v0.72.0
func (v *KeywordTransformer) SQL(sqlPrefix string) *KeywordTransformer
func (*KeywordTransformer) SingleQuotes ¶ added in v0.72.0
func (v *KeywordTransformer) SingleQuotes() *KeywordTransformer
func (*KeywordTransformer) Transform ¶ added in v0.72.0
func (v *KeywordTransformer) Transform(f *Field) *Field
type ListTransformer ¶ added in v0.72.0
type ListTransformer struct {
// contains filtered or unexported fields
}
func ListOptions ¶ added in v0.72.0
func ListOptions() *ListTransformer
func (*ListTransformer) NoEquals ¶ added in v0.73.0
func (v *ListTransformer) NoEquals() *ListTransformer
func (*ListTransformer) NoParentheses ¶ added in v0.74.0
func (v *ListTransformer) NoParentheses() *ListTransformer
func (*ListTransformer) Parentheses ¶ added in v0.74.0
func (v *ListTransformer) Parentheses() *ListTransformer
func (*ListTransformer) Required ¶ added in v0.72.0
func (v *ListTransformer) Required() *ListTransformer
func (*ListTransformer) SQL ¶ added in v0.72.0
func (v *ListTransformer) SQL(sqlPrefix string) *ListTransformer
func (*ListTransformer) Transform ¶ added in v0.72.0
func (v *ListTransformer) Transform(f *Field) *Field
type Operation ¶
type Operation struct { // Name is the operation's name, e.g. "Create" Name string // ObjectInterface points to the containing interface ObjectInterface *Interface // Doc is the URL for the doc used to create given operation, e.g. https://docs.snowflake.com/en/sql-reference/sql/create-database-role Doc string // OptsField defines opts used to create SQL for given operation OptsField *Field // HelperStructs are struct definitions that are not tied to OptsField, but tied to the Operation itself, e.g. Show() return type HelperStructs []*Field // ShowMapping is a definition of mapping needed by Operation kind of OperationKindShow ShowMapping *Mapping // DescribeKind defines a kind of mapping that needs to be performed in particular case of Describe implementation DescribeKind *DescriptionMappingKind // DescribeMapping is a definition of mapping needed by Operation kind of OperationKindDescribe DescribeMapping *Mapping }
Operation defines a single operation for given object or objects family (e.g. CREATE DATABASE ROLE)
type OperationKind ¶ added in v0.72.0
type OperationKind string
const ( OperationKindCreate OperationKind = "Create" OperationKindAlter OperationKind = "Alter" OperationKindDrop OperationKind = "Drop" OperationKindShow OperationKind = "Show" OperationKindShowByID OperationKind = "ShowByID" OperationKindDescribe OperationKind = "Describe" )
type ParameterTransformer ¶ added in v0.72.0
type ParameterTransformer struct {
// contains filtered or unexported fields
}
func ParameterOptions ¶ added in v0.72.0
func ParameterOptions() *ParameterTransformer
func (*ParameterTransformer) ArrowEquals ¶ added in v0.74.0
func (v *ParameterTransformer) ArrowEquals() *ParameterTransformer
func (*ParameterTransformer) DoubleQuotes ¶ added in v0.72.0
func (v *ParameterTransformer) DoubleQuotes() *ParameterTransformer
func (*ParameterTransformer) NoEquals ¶ added in v0.73.0
func (v *ParameterTransformer) NoEquals() *ParameterTransformer
func (*ParameterTransformer) NoParentheses ¶ added in v0.73.0
func (v *ParameterTransformer) NoParentheses() *ParameterTransformer
func (*ParameterTransformer) NoQuotes ¶ added in v0.72.0
func (v *ParameterTransformer) NoQuotes() *ParameterTransformer
func (*ParameterTransformer) Parentheses ¶ added in v0.72.0
func (v *ParameterTransformer) Parentheses() *ParameterTransformer
func (*ParameterTransformer) Required ¶ added in v0.72.0
func (v *ParameterTransformer) Required() *ParameterTransformer
func (*ParameterTransformer) SQL ¶ added in v0.72.0
func (v *ParameterTransformer) SQL(sqlPrefix string) *ParameterTransformer
func (*ParameterTransformer) SingleQuotes ¶ added in v0.72.0
func (v *ParameterTransformer) SingleQuotes() *ParameterTransformer
func (*ParameterTransformer) Transform ¶ added in v0.72.0
func (v *ParameterTransformer) Transform(f *Field) *Field
type TagBuilder ¶ added in v0.72.0
type TagBuilder struct {
// contains filtered or unexported fields
}
func Tags ¶ added in v0.72.0
func Tags() *TagBuilder
func (*TagBuilder) Build ¶ added in v0.72.0
func (v *TagBuilder) Build() map[string][]string
func (*TagBuilder) DB ¶ added in v0.72.0
func (v *TagBuilder) DB(db ...string) *TagBuilder
func (*TagBuilder) DDL ¶ added in v0.72.0
func (v *TagBuilder) DDL(ddl ...string) *TagBuilder
func (*TagBuilder) Identifier ¶ added in v0.72.0
func (v *TagBuilder) Identifier() *TagBuilder
func (*TagBuilder) Keyword ¶ added in v0.72.0
func (v *TagBuilder) Keyword() *TagBuilder
func (*TagBuilder) List ¶ added in v0.72.0
func (v *TagBuilder) List() *TagBuilder
func (*TagBuilder) NoEquals ¶ added in v0.73.0
func (v *TagBuilder) NoEquals() *TagBuilder
func (*TagBuilder) NoParentheses ¶ added in v0.72.0
func (v *TagBuilder) NoParentheses() *TagBuilder
func (*TagBuilder) Parameter ¶ added in v0.72.0
func (v *TagBuilder) Parameter() *TagBuilder
func (*TagBuilder) Parentheses ¶ added in v0.73.0
func (v *TagBuilder) Parentheses() *TagBuilder
func (*TagBuilder) SQL ¶ added in v0.72.0
func (v *TagBuilder) SQL(sql ...string) *TagBuilder
func (*TagBuilder) SingleQuotes ¶ added in v0.73.0
func (v *TagBuilder) SingleQuotes() *TagBuilder
func (*TagBuilder) Static ¶ added in v0.72.0
func (v *TagBuilder) Static() *TagBuilder
type Validation ¶
type Validation struct { Type ValidationType FieldNames []string }
func NewValidation ¶
func NewValidation(validationType ValidationType, fieldNames ...string) *Validation
func (*Validation) Condition ¶
func (v *Validation) Condition(field *Field) string
func (*Validation) ReturnedError ¶ added in v0.72.0
func (v *Validation) ReturnedError(field *Field) string
func (*Validation) TodoComment ¶
func (v *Validation) TodoComment(field *Field) string
type ValidationType ¶
type ValidationType int64
ValidationType contains all handled validation types. Below validations are marked to be contained here or not: - opts not nil - not present here, handled on template level - valid identifier - present here, for now put on level containing given field - conflicting fields - present here, put on level containing given fields - exactly one value set - present here, put on level containing given fields - at least one value set - present here, put on level containing given fields - validate nested field - present here, used for common structs which have their own validate() methods specified - nested validation conditionally - not present here, handled by putting validations on lower level fields
const ( ValidIdentifier ValidationType = iota ValidIdentifierIfSet ConflictingFields ExactlyOneValueSet AtLeastOneValueSet ValidateValue )