Documentation ¶
Overview ¶
Package inference defines process that automatically determines the data type of a variable or expression from database meta information
Index ¶
- func ExtractColumnConfig(column *sqlparser.Column) (*view.ColumnConfig, error)
- func ExtractRelationColumns(join *query.Join) (string, string)
- func HasWhitespace(text string) bool
- func HintToStruct(encoded string, aStructPtr interface{}) error
- func IsToOne(join *query.Join) bool
- func ParentAlias(join *query.Join) string
- func PkgPath(fieldName string, pkgPath string) (fieldPath string)
- func SplitByWhitespace(fragment string) []string
- func SqlxTag(tag reflect.StructTag) *io.Tag
- func TrimParenthesis(text string) string
- func TryUnmarshalHint(hint string, any interface{}) error
- type ColumnParameterNamer
- type Field
- type Imports
- type ModificationSetting
- type Parameter
- func (p *Parameter) AppendComposite(baseParameter *Parameter)
- func (p *Parameter) DsqlOutputParameterDeclaration() string
- func (p *Parameter) DsqlParameterDeclaration() string
- func (p *Parameter) EnsureCodec()
- func (p *Parameter) EnsureLocation()
- func (p *Parameter) EnsureSchema()
- func (p *Parameter) FieldDeclaration(embedRoot string, embed map[string]string, def *view.TypeDefinition) string
- func (p *Parameter) HasDataType() bool
- func (p *Parameter) HasSchema() bool
- func (p *Parameter) IndexFieldDeclaration() string
- func (p *Parameter) IndexVariable() string
- func (p *Parameter) LocalVariable() string
- func (p *Parameter) MergeFrom(info *Parameter)
- func (p *Parameter) SyncObject()
- type ReflectOption
- type Relation
- type Selector
- type Spec
- func (s *Spec) AddRelation(name string, join *query.Join, spec *Spec, cardinality state.Cardinality) error
- func (s *Spec) BuildType(pkg, name string, cardinality state.Cardinality, ...) error
- func (s *Spec) EnsureRelationType()
- func (s *Spec) Fields(includeHas bool, doc state.Documentation) []*view.Field
- func (s *Spec) NormalizeSQL()
- func (s *Spec) PkStructQL(selector Selector) (*Field, string)
- func (s *Spec) Selector(rootPath string) Selector
- func (s *Spec) TypeDefinition(wrapper string, includeHas bool, doc state.Documentation) *view.TypeDefinition
- func (s *Spec) ViewSQL(columnParameter ColumnParameterNamer) string
- type State
- func (s State) AddDescriptions(doc state.Documentation)
- func (s *State) AdjustOutput() error
- func (s *State) Append(params ...*Parameter) bool
- func (s *State) AppendConst(constants map[string]interface{})
- func (s *State) AppendParameters(parameters ...state.Parameters)
- func (s *State) AppendViewParameters(params ...*state.Parameter)
- func (s State) BodyField() string
- func (s *State) BodyParameter() *Parameter
- func (s State) Clone() State
- func (s State) Compact(modulePath string, registry *xreflect.Types) (State, error)
- func (s State) DsqlOutputParameterDeclaration() string
- func (s State) DsqlParameterDeclaration() string
- func (s State) EnsureReflectTypes(modulePath string, pkg string, registry *xreflect.Types) error
- func (s State) EnsureStructQLTypes() error
- func (s State) Expand(text string) string
- func (s State) Explicit() State
- func (s State) FilterByKind(kind state.Kind) State
- func (s *State) GetOutputParameter() *Parameter
- func (s State) HandlerLocalVariables() ([]string, string)
- func (s State) Has(name string) bool
- func (s State) Implicit() State
- func (s State) IndexByName() map[string]*Parameter
- func (s State) IndexByPathIndex() map[string]*Parameter
- func (s State) Lookup(name string) *Parameter
- func (s State) MetaViewSQL() *Parameter
- func (s State) NormalizeComposites() (State, error)
- func (s State) Parameters() state.Parameters
- func (s State) ReflectType(pkgPath string, lookupType xreflect.LookupType) (reflect.Type, error)
- func (s State) RemoveReserved() State
- func (s *State) StateForSQL(SQL string, isRoot bool) State
- type Table
- type TagValue
- type Tags
- type Type
- func (t *Type) AddRelation(name string, spec *Spec, relation *Relation) *Field
- func (t *Type) AppendColumnField(column *sqlparser.Column, skipped bool, doc state.Documentation, table string) (*Field, error)
- func (t *Type) ByColumn(name string) *Field
- func (t *Type) ColumnFields(table string, doc state.Documentation) []*view.Field
- func (t *Type) ExpandType(simpleName string) string
- func (t *Type) Fields(opts ...ReflectOption) []reflect.StructField
- func (t *Type) SimplePackage() string
- func (t *Type) TypeName() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractColumnConfig ¶
func ExtractColumnConfig(column *sqlparser.Column) (*view.ColumnConfig, error)
func HasWhitespace ¶
func HintToStruct ¶
func ParentAlias ¶
ParentAlias returns join parent selector
func SplitByWhitespace ¶
func TrimParenthesis ¶
func TryUnmarshalHint ¶
Types ¶
type ColumnParameterNamer ¶
type Field ¶
type Field struct { view.Field Skipped bool Column *sqlparser.Column Pk *sink.Key Tags Tags Ptr bool ColumnCase text.CaseFormat Relation string }
func NewField ¶
func NewField(rField *reflect.StructField) *Field
func (*Field) EnsureSchema ¶
func (*Field) StructField ¶
func (f *Field) StructField(opts ...ReflectOption) reflect.StructField
type Imports ¶
func NewImports ¶
func NewImports() Imports
func (*Imports) AddPackage ¶
func (*Imports) DefaultPackageImports ¶
func (*Imports) PackageImports ¶
func (*Imports) RawImports ¶
func (*Imports) TypeImports ¶
type ModificationSetting ¶
type Parameter ¶
type Parameter struct { Explicit bool //explicit parameter are added to the main view as dependency state.Parameter Repeated State Object State ModificationSetting SQL string Hint string AssumedType bool Connector string InOutput bool Of string }
func NewConstParameter ¶
func NewPathParameter ¶
func (*Parameter) AppendComposite ¶
func (*Parameter) DsqlOutputParameterDeclaration ¶ added in v0.10.0
func (*Parameter) DsqlParameterDeclaration ¶
func (*Parameter) EnsureCodec ¶
func (p *Parameter) EnsureCodec()
func (*Parameter) EnsureLocation ¶
func (p *Parameter) EnsureLocation()
func (*Parameter) EnsureSchema ¶
func (p *Parameter) EnsureSchema()
func (*Parameter) FieldDeclaration ¶
func (*Parameter) HasDataType ¶
func (*Parameter) IndexFieldDeclaration ¶ added in v0.10.0
func (*Parameter) IndexVariable ¶
func (*Parameter) LocalVariable ¶
func (*Parameter) SyncObject ¶
func (p *Parameter) SyncObject()
type ReflectOption ¶
type ReflectOption func(r *reflectOptions)
func WithStructTag ¶
func WithStructTag() ReflectOption
type Relation ¶
type Relation struct { Name string Join *query.Join ParentField *Field KeyField *Field Cardinality state.Cardinality *Spec }
Relation defines relation
type Spec ¶
type Spec struct { Namespace string Parent *Spec Package string IsAuxiliary bool Table string SQL string SQLArgs []interface{} Columns sqlparser.Columns Fk map[string]sink.Key Type *Type Relations []*Relation // contains filtered or unexported fields }
Spec defines table/sql base specification
func NewSpec ¶
func NewSpec(ctx context.Context, db *sql.DB, messages *msg.Messages, table, SQL string, SQLArgs ...interface{}) (*Spec, error)
NewSpec discover column derived type for supplied SQL/table
func (*Spec) AddRelation ¶
func (s *Spec) AddRelation(name string, join *query.Join, spec *Spec, cardinality state.Cardinality) error
AddRelation adds relations
func (*Spec) BuildType ¶
func (s *Spec) BuildType(pkg, name string, cardinality state.Cardinality, whitelist, blacklist map[string]bool, doc state.Documentation) error
BuildType build a type from infered table/SQL definition
func (*Spec) EnsureRelationType ¶
func (s *Spec) EnsureRelationType()
func (*Spec) NormalizeSQL ¶ added in v0.10.1
func (s *Spec) NormalizeSQL()
func (*Spec) PkStructQL ¶
PkStructQL crates a PK struct SQL
func (*Spec) TypeDefinition ¶
func (s *Spec) TypeDefinition(wrapper string, includeHas bool, doc state.Documentation) *view.TypeDefinition
TypeDefinition builds spec based tyep definition
func (*Spec) ViewSQL ¶
func (s *Spec) ViewSQL(columnParameter ColumnParameterNamer) string
ViewSQL return structQL SQL for relation
type State ¶
type State []*Parameter
State defines datly view/resource parameters
func (State) AddDescriptions ¶
func (s State) AddDescriptions(doc state.Documentation)
func (*State) AdjustOutput ¶
func (*State) AppendConst ¶
func (*State) AppendParameters ¶
func (s *State) AppendParameters(parameters ...state.Parameters)
func (*State) AppendViewParameters ¶
func (*State) BodyParameter ¶ added in v0.10.0
func (State) DsqlOutputParameterDeclaration ¶ added in v0.10.0
DsqlOutputParameterDeclaration returns dql parameter declaration
func (State) DsqlParameterDeclaration ¶
DsqlParameterDeclaration returns dql parameter declaration
func (State) EnsureReflectTypes ¶
func (State) EnsureStructQLTypes ¶ added in v0.9.7
func (State) FilterByKind ¶
FilterByKind filters state parameter by kind
func (*State) GetOutputParameter ¶
func (State) HandlerLocalVariables ¶
HandlerLocalVariables returns golang handler local variables reassigned from state
func (State) IndexByName ¶
IndexByName indexes parameter by name
func (State) IndexByPathIndex ¶
IndexByPathIndex indexes parameter by index variable
func (State) MetaViewSQL ¶
func (State) NormalizeComposites ¶
NormalizeComposites normalizes state
func (State) Parameters ¶
func (s State) Parameters() state.Parameters
func (State) ReflectType ¶
func (State) RemoveReserved ¶
type Table ¶
type Table struct { Name string Namespace string Columns sqlparser.Columns QueryColumns sqlparser.Columns Tables []*Table OutputJSONHint string // contains filtered or unexported fields }
func (*Table) AppendTable ¶
func (*Table) HasNamespace ¶
type Type ¶
type Type struct { Package string Name string Cardinality state.Cardinality PkFields []*Field RelationFields []*Field // contains filtered or unexported fields }
func (*Type) AddRelation ¶
func (*Type) AppendColumnField ¶
func (*Type) ColumnFields ¶
func (*Type) ExpandType ¶
func (*Type) Fields ¶
func (t *Type) Fields(opts ...ReflectOption) []reflect.StructField