Documentation
¶
Index ¶
- func AllowedFieldByType(expr ast.Expr, pkgAlias string, imports []Import, filePath string) bool
- func ImplementsAllowedInterfaces(typ types.Type) bool
- func New() *cobra.Command
- func RenderSQLTemplate(tmpl string) (string, error)
- func ResolveTypeFromExpr(expr ast.Expr, imports []Import, filePath string, preferAlias string) types.Type
- type ExtractedSQL
- type Field
- type File
- type ForNode
- type FuncNode
- type Generator
- type IfBranch
- type IfNode
- type Import
- type Interface
- type Method
- type Node
- type Param
- type Struct
- type TextNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowedFieldByType ¶
AllowedFieldByType returns true if the field type should be treated as a simple, allowed column type. Rules: - Primitive numbers, bool, string - time.Time, []byte - Any named type that implements one of the allowed interfaces
func ImplementsAllowedInterfaces ¶
ImplementsAllowedInterfaces reports whether typ or *typ implements any allowed interface.
func RenderSQLTemplate ¶
RenderSQLTemplate parses the template string and returns Go code or an error.
func ResolveTypeFromExpr ¶
func ResolveTypeFromExpr(expr ast.Expr, imports []Import, filePath string, preferAlias string) types.Type
ResolveTypeFromExpr attempts to resolve a types.Type for a field's AST expression. - Supports selector expressions (pkg.Type) - Supports identifiers from the current package (exported) - Ignores basic built-in types (lowercase idents) - Follows one level of pointers
Types ¶
type Field ¶
type Field struct { Name string DBName string GoType string GoTypeAlias string Tag string // contains filtered or unexported fields }
func (Field) Type ¶
Type returns the field type string for template generation
type File ¶
type ForNode ¶
ForNode for {{for expr}}.
type FuncNode ¶
FuncNode for {{where}} / {{set}} blocks.
type IfBranch ¶
IfBranch holds one condition + body.
type IfNode ¶
IfNode can have multiple branches (if, else if, else if, ...), plus an optional else.
type Import ¶
type Interface ¶
type Method ¶
type Method struct { Name string Doc string SQL ExtractedSQL Params []Param Result []Param Interface Interface }
func (Method) Body ¶
Body generates the method body code for templates
func (Method) ParamsString ¶
ParamsString formats method parameters as a string for code generation
type Node ¶
Node is the interface that all AST nodes implement.
type Param ¶
Source Files
¶
- gen.go
- generator.go
- sqlparser.go
- template.go
- utils.go