preformShare

package
v0.0.0-...-1e4cd2d Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildingModels       = map[reflect.Type]IFactoryBuilder{}
	BuildingSchemas      = map[reflect.Type]any{}
	BuildingModelsByName = map[string]IFactoryBuilder{}
	BuildingQueries      = map[string]IQueryBuilder{}

	DEFAULT_VALUE = &struct{}{}

	CTX_LOGGER = &struct{}{}
)

Functions

func NestCondSql

func NestCondSql(query string, args []any, dialect ...IDialect) (string, []any, error)

func NestSql

func NestSql(query string, args []any, dialect ...IDialect) (string, []any, error)

Types

type Aggregator

type Aggregator string

type Column

type Column struct {
	Name         string
	Type         string
	GoType       string
	Nullable     bool
	IsPrimaryKey bool
	PkPos        int64
	IsAutoKey    bool
	Comment      string
	ForeignKeys  []*ForeignKey
	Table        *Table `json:"-"`
	DefaultValue sql.NullString
	IColDef      IColDef
	IsScanner    bool
}

type CustomType

type CustomType struct {
	Name    string
	Attr    []*CustomTypeAttr
	Imports map[string]struct{}
}

type CustomTypeAttr

type CustomTypeAttr struct {
	Name      string
	Type      string
	NotNull   bool
	IsScanner bool
}

type DbQueryRunner

type DbQueryRunner interface {
	Prepare(query string) (*sql.Stmt, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	Preparex(query string) (*sqlx.Stmt, error)
	PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
	Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
	QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
	QueryRowx(query string, args ...interface{}) *sqlx.Row
	QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
}

type DeleteBuilder

type DeleteBuilder = squirrel.DeleteBuilderFast

type ForeignKey

type ForeignKey struct {
	Name         string
	LocalKeys    []*Column
	ForeignKeys  []*Column
	RelationName string
	ReverseName  string
	AssociatedFk *ForeignKey
}

type IArrayTypes

type IArrayTypes interface {
	IterAny() []any
}

type ICol

type ICol interface {
	IField
	DbName() string
	GetCode() string
	GetCodeWithAlias() string
	SetValue(any, any)
	GetPos() int
}

type IColDef

type IColDef interface {
	SrcName() string
	CodeName() string
	Alias() string
	SetAliasI(string) IColDef
	OColName() string
	GetType() reflect.Type
	Factory() IFactoryBuilder
	GenerateCode(schemaName string, fromQuery bool) (importPath []string, defColCode []string, modelColCode []string, settingCode []string, extraFunc string)
	ColDef() IColDef

	RelatedFks() []IColDef
}

type ICondForBuilder

type ICondForBuilder interface {
	ToCode() (code string)
	ToCondCode() (code string)
	IAnd(conds ...ICondForBuilder) ICondForBuilder
	UseAlias(...IColDef) ICondForBuilder
}

type IDialect

type IDialect interface {
	QuoteIdentifier(string) string
	GetStructure(db *sql.DB, schemasEmptyIsAll ...string) []*Scheme
	Aggregate(fn Aggregator, body any, params ...any) squirrel.Sqlizer
	LastInsertIdMethod() (method SqlDialectLastInsertIdMethod, suffix func(col string) squirrel.Sqlizer)
	UpdateSqlizer(UpdateBuilder) (string, []any, error) //for clickhouse
	DeleteSqlizer(DeleteBuilder) (string, []any, error) //for clickhouse
	ValueParsers() map[reflect.Type]any
	DefaultValueExpr() squirrel.Sqlizer
	ParseCustomTypeScan(src any) (dst []string, err error)
	ParseCustomTypeValue(name string, src ...any) (dst string, err error)
	CaseStmtToSql(builder squirrel.CaseBuilder, col ICol) (string, []any, error)
	//condition
	Eq(col ICol, v any) squirrel.Sqlizer
	NotEq(col ICol, v any) squirrel.Sqlizer
	Like(col ICol, v any) squirrel.Sqlizer
	Gt(col ICol, v any) squirrel.Sqlizer
	GtOrEq(col ICol, v any) squirrel.Sqlizer
	Lt(col ICol, v any) squirrel.Sqlizer
	LtOrEq(col ICol, v any) squirrel.Sqlizer
	Between(col ICol, v1, v2 any) squirrel.Sqlizer

	ArrayEq(arrCol any, value any) (query string, args []any, err error)
	ArrayAny(arrCol any, value any) (query string, args []any, err error)
	ArrayHasAny(arrColA any, arrColB any) (query string, args []any, err error)
	ArrayConcat(arrColA any, arrColB any) (query string, args []any, err error)
	ArrayContains(arrColA any, arrColB any) (query string, args []any, err error)
	ArrayContainsBy(arrColA any, arrColB any) (query string, args []any, err error)
}

type IFactoryBuilder

type IFactoryBuilder interface {
	CodeName() string
	FullCodeName() string
	SchemaName() string
	TableName() string
	FactoryType() reflect.Type
	SetAlias(alias string) IFactoryBuilder
	Alias() string
	ColSet() map[string]IColDef
	Cols() []IColDef
	PK() []IColDef
	Clone() IFactoryBuilder
	AddCode(def, model, setting, extraFuncs []string, setRelationCodes [][]string)
}

type IFactoryBuilderWithSetup

type IFactoryBuilderWithSetup interface {
	Setup() (skipAutoSetter bool)
}

type IField

type IField interface {
	Name() string
	NewValue() any
	ParentModel() any
}

type ILogLv

type ILogLv interface {
	UnmarshalJSON(b []byte) error
	Lv() uint32
}

type IQueryBuilder

type IQueryBuilder interface {
}

type IQueryFactory

type IQueryFactory interface {
	TableNames() []string
}

type ISqlizerWithDialect

type ISqlizerWithDialect interface {
	WithDialect(iDialect IDialect) squirrel.Sqlizer
	ToSql(dialect IDialect) (string, []interface{}, error)
}

type ITestQueryRunner

type ITestQueryRunner interface {
	DbQueryRunner
	IsTester()
}

type ITestSqlConnectorDriver

type ITestSqlConnectorDriver interface {
	TestDriverName() string
}

type LogLv

type LogLv uint32
const (
	LogLv_Exec   LogLv = 1
	LogLv_Read   LogLv = 2
	LogLv_Health LogLv = 4
)

func (LogLv) Lv

func (o LogLv) Lv() uint32

func (*LogLv) UnmarshalJSON

func (o *LogLv) UnmarshalJSON(b []byte) error

type QueryRunner

type QueryRunner interface {
	DbQueryRunner
	InsertAndReturnAutoId(ctx context.Context, lastIdMethod SqlDialectLastInsertIdMethod, query string, args ...any) (int64, error)
	BaseRunner() DbQueryRunner
	RelatedFactory([]IQueryFactory) QueryRunner
}

type Scheme

type Scheme struct {
	Tables      []*Table
	Name        string
	Imports     map[string]struct{}
	Enums       map[string][]string
	CustomTypes map[string]*CustomType
}

InsertBuilder = squirrel.InsertBuilderFast

type SelectBuilder

type SelectBuilder = squirrel.SelectBuilderFast

type SqlDialectLastInsertIdMethod

type SqlDialectLastInsertIdMethod uint32

type SqlizerWithDialectWrapper

type SqlizerWithDialectWrapper struct {
	Sqlizer func() (string, []interface{}, error)
}

func (SqlizerWithDialectWrapper) ToSql

func (s SqlizerWithDialectWrapper) ToSql() (string, []interface{}, error)

type Table

type Table struct {
	Name          string
	Columns       []*Column
	Comment       string
	Scheme        *Scheme            `json:"-"`
	ColumnByName  map[string]*Column `json:"-"`
	Imports       map[string]struct{}
	Inheritors    [][3]string
	IsView        bool
	IsMiddleTable bool
	ForeignKeys   map[string]*ForeignKey
	Sql           string
}

type UpdateBuilder

type UpdateBuilder = squirrel.UpdateBuilderFast

Jump to

Keyboard shortcuts

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