struct_info

package
v0.0.0-...-912f3db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JoinLeft LEFT JOIN тип.
	JoinLeft = "left"
	// JoinRight RIGHT JOIN тип.
	JoinRight = "right"
	// JoinInner INNER JOIN тип.
	JoinInner = "inner"
)

Variables

View Source
var SqlBuilderVal sqlBuilder

Functions

This section is empty.

Types

type FieldTagFlags

type FieldTagFlags struct {
	IsPK        bool // keyPK
	ReadOnly    bool // keyRO
	AutoGen     bool // keyAuto
	Embed       bool
	ForceUpdate bool
	ForceInsert bool
	SkipReading bool
	ColName     string // keyColName
	Prefix      string // keyPrefix
	Ref         string
	Sort        string
}

func (*FieldTagFlags) Merge

func (f *FieldTagFlags) Merge(parent FieldTagFlags)

type JoinCondition

type JoinCondition struct {
	TargetAlias  string // алиас referenced таблицы / alias of referenced table
	TargetColumn string // referenced column name
	SourceColumn string // колонка в source таблице с ref= / column in source table with ref=
}

JoinCondition описывает условие ON для JOIN. EN: JoinCondition describes an ON condition for JOIN.

type QueryInfo

type QueryInfo struct {
	Tables         []QueryTableInfo
	FromIdx        int
	PKIdx          int
	CombinedFields TableFields
	SelectIdxList  []int
	SortIdxList    []int
	FieldNameIdx   map[string]int
}

QueryInfo полная метаинформация для Query[T]. EN: QueryInfo full metadata for Query[T].

func CollectQueryInfo

func CollectQueryInfo(t reflect.Type) (QueryInfo, error)

CollectQueryInfo собирает метаинформацию для Query-структуры T. EN: CollectQueryInfo collects metadata for Query struct T.

type QuerySqlTexts

type QuerySqlTexts struct {
	GetOne    string // SELECT ... FROM ... JOINs ... WHERE pk = $1
	ListStart string // SELECT ... FROM ... JOINs ...
	SortPart  string // ORDER BY ...
}

QuerySqlTexts SQL тексты для Query[T]. EN: QuerySqlTexts SQL texts for Query[T].

func BuildQuerySqlTexts

func BuildQuerySqlTexts(d dialect.SQLDialect, qi *QueryInfo) QuerySqlTexts

BuildQuerySqlTexts строит SQL тексты для Query на основе QueryInfo. EN: BuildQuerySqlTexts builds SQL texts for Query based on QueryInfo.

type QueryTableInfo

type QueryTableInfo struct {
	TableInfo  TableInfo
	Alias      string
	JoinType   string // "left", "right", "inner"
	IsFrom     bool
	IsPK       bool
	IsPointer  bool
	FieldIndex int
	SortPos    int
	RefMap     map[string]string
	JoinConds  []JoinCondition
}

QueryTableInfo метаинформация для одной таблицы в Query. EN: QueryTableInfo metadata for one table in Query.

type QueryTagFlags

type QueryTagFlags struct {
	IsFrom   bool
	JoinType string            // "left", "right", "inner", "" (auto)
	Alias    string            // SQL alias for this table
	RefMap   map[string]string // ref-table-name → alias
	IsPK     bool
	IsOmit   bool
	SortPos  int
}

QueryTagFlags флаги тега tbl на полях Query-структуры. EN: QueryTagFlags flags of the tbl tag on Query struct fields.

func ParseQueryTag

func ParseQueryTag(tag string) (QueryTagFlags, error)

ParseQueryTag парсит тег tbl на полях Query-структуры. EN: ParseQueryTag parses the tbl tag on Query struct fields.

type SQLNamer

type SQLNamer interface {
	SQLName() string
}

type SqlTexts

type SqlTexts struct {
	Insert    string
	Update    string
	Delete    string
	GetOne    string
	ListStart string
	SortPart  string
}

type TableField

type TableField struct {
	Index        []int
	Path         []string
	SQLName      string
	RefTable     string
	RefField     string
	SortPos      int
	IsPK         bool // keyPK
	CanSelect    bool
	CanInsert    bool
	CanUpdate    bool
	SortBackward bool
}

type TableFields

type TableFields []TableField

func CollectTableFields

func CollectTableFields(t reflect.Type) (TableFields, error)

func (TableFields) ExtractArgs

func (tfs TableFields) ExtractArgs(src any, indexes []int) []any

func (TableFields) ExtractRefs

func (tfs TableFields) ExtractRefs(src any, indexes []int) (refs []any)

type TableInfo

type TableInfo struct {
	SQLName       string
	Fields        TableFields
	PKIdxList     []int
	InsertIdxList []int
	UpdateIdxList []int
	SelectIdxList []int
	SortIdxList   []int
	RefIdxList    []int
	FieldNameIdx  map[string]int
}

func GetTableInfo

func GetTableInfo(t reflect.Type) (TableInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL