Versions in this module Expand all Collapse all v1 v1.2.0 Aug 27, 2026 v1.1.1 Aug 26, 2026 v1.1.0 Aug 26, 2026 v1.0.0 Aug 21, 2026 Changes in this version + func EndWithSemicolon(sql string) string + func EscapeLikePattern(pattern string, t LikePatternType) string + func FormatValue(v interface{}, colType StandardFieldType) (string, error) + func GetDBAndTable(cli DatabaseClient, viewName ...string) (string, string, error) + func InMapParam(ids map[string]struct{}) string + func InParam(ids []string) string + func InParam2(ids [][]string) string + func StrVal(v any) string + type BetweenCondition struct + End Expression + Expr Expression + Not bool + Start Expression + type BinaryExpr struct + Alias string + Left Expression + Operator string + Right Expression + func (b *BinaryExpr) As(alias string) *BinaryExpr + type BooleanCondition struct + Args []Condition + Operator string + type BuildOptions struct + DBSubType string + Flavor Flavor + InlineLiterals bool + QmMarker string + type CaseExpr struct + Alias string + Else Expression + Value Expression + Whens []WhenThen + func (c *CaseExpr) As(alias string) *CaseExpr + type CastExpr struct + Alias string + Expr Expression + Type string + func (c *CastExpr) As(alias string) *CastExpr + type ColumnExpr struct + Alias string + Name string + Schema string + Table string + func (c *ColumnExpr) As(alias string) *ColumnExpr + type ColumnInfo interface + GetComment func() string + GetDefault func() *string + GetForeignKey func() ForeignKeyInfo + GetName func() string + GetOrginalDataType func() string + GetPrecision func() int + GetScale func() int + GetSize func() int + GetType func() StandardFieldType + GetTypeAndSize func() (StandardFieldType, int) + IsAutoIncrement func() bool + IsDefaultCurrentTimeOnCreate func() bool + IsDefaultCurrentTimeOnUpdate func() bool + IsIndex func() bool + IsNotNull func() bool + IsPrimaryKey func() bool + IsUnique func() bool + type CommonTableExpr struct + Columns []string + Name string + Query SQLStmt + Recursive bool + type ComparisonCondition struct + Left Expression + Operator string + Right Expression + type CompositeForeignKey interface + GetColumns func() []string + GetName func() string + GetOnDelete func() ForeignKeyAction + GetOnUpdate func() ForeignKeyAction + GetRefColumns func() []string + GetRefTable func() string + type CompositeIndex interface + GetColumns func() []string + GetName func() string + IsUnique func() bool + type Condition interface + type Config struct + Connections []DBConnection + type DBConnection struct + CompatCollation bool + ConnectTimeout int + DBName string + EnsureDB bool + Host string + Key string + Path string + Pool *PoolConfig + Port int + Pw string + Role string + SSLMode string + Schema string + Service string + SubType string + Type string + Un string + type DBExecutor interface + DBSubType func() string + DBType func() string + DirectNamedExecute func(sql string, params any) (int64, error) + DirectNamedExecuteContext func(ctx context.Context, sql string, params any) (int64, error) + DirectNamedForEachQueryContext func(ctx context.Context, tableName string, selectSQL string, data any, ...) error + DirectNamedInsert func(sql string, data any) (int64, error) + DirectNamedInsertContext func(ctx context.Context, sql string, data any) (int64, error) + DirectNamedQueryAsResult func(sql string, params any) QueryResult + DirectNamedQueryAsResultContext func(ctx context.Context, sql string, params any) QueryResult + GetTableInfo func(tableName string) (TableInfo, error) + NamedForEachQuery func(tableName string, selectSQL string, data any, fn func(RowData) error) error + NamedQueryAsResult func(sql string, params any) QueryResult + NamedQueryAsResultContext func(ctx context.Context, sql string, params any) QueryResult + type DatabaseClient interface + Close func() error + DBSubType func() string + DBType func() string + Database func() string + DirectExcute func(sql string, arguments ...interface{}) (int64, error) + DirectExecute func(sql string, arguments ...interface{}) (int64, error) + DirectNQuery func(sql string, data any) ([]map[string]any, error) + DirectNQueryRow func(sql string, data any) (map[string]any, error) + DirectNamedExecute func(sql string, data any) (int64, error) + DirectNamedExecuteContext func(ctx context.Context, sql string, data any) (int64, error) + DirectNamedForEachQuery func(tableName string, sql string, data any, fn func(RowData) error) error + DirectNamedForEachQueryContext func(ctx context.Context, tableName string, sql string, data any, ...) error + DirectNamedInsert func(sql string, data any) (int64, error) + DirectNamedInsertContext func(ctx context.Context, sql string, data any) (int64, error) + DirectNamedQuery func(sql string, data any) ([]map[string]any, error) + DirectNamedQueryAsResult func(sql string, params any) QueryResult + DirectNamedQueryAsResultContext func(ctx context.Context, sql string, params any) QueryResult + DirectNamedQueryRow func(sql string, data any) (map[string]interface{}, error) + DirectQuery func(sql string, args ...interface{}) ([]map[string]interface{}, error) + DirectQueryRow func(sql string, args ...interface{}) (map[string]interface{}, error) + Excute func(sql string, arguments ...interface{}) (int64, error) + Execute func(sql string, arguments ...interface{}) (int64, error) + First func(tableName string, data map[string]any, cc ...QueryOption) (map[string]any, error) + FirstContext func(ctx context.Context, tableName string, data map[string]any, cc ...QueryOption) (map[string]any, error) + ForEachQuery func(tableName string, sql string, fn func(row RowData) error) error + Get func(dest interface{}, query string, args ...interface{}) error + GetTableInfo func(tableName string) (TableInfo, error) + Insert func(tableName string, data map[string]any, cc ...QueryOption) (int64, error) + InsertContext func(ctx context.Context, tableName string, data map[string]any, cc ...QueryOption) (int64, error) + IsTableExist func(tableName string) (bool, error) + List func(tableName string, data map[string]any, cc ...QueryOption) ([]map[string]any, error) + ListContext func(ctx context.Context, tableName string, data map[string]any, cc ...QueryOption) ([]map[string]any, error) + ListWithPage func(tableName string, param map[string]any, page, pageSize int, cc ...QueryOption) ([]map[string]any, int64, error) + ListWithPageContext func(ctx context.Context, tableName string, param map[string]any, ...) ([]map[string]any, int64, error) + NQuery func(sql string, data any) ([]map[string]any, error) + NQueryRow func(sql string, data any) (map[string]any, error) + NamedExecute func(sql string, data any) (int64, error) + NamedForEachQuery func(tableName string, selectSQL string, data any, fn func(RowData) error) error + NamedForEachQueryContext func(ctx context.Context, tableName string, selectSQL string, data any, ...) error + NamedQuery func(sql string, data any) ([]map[string]any, error) + NamedQueryAsResult func(sql string, data any) QueryResult + NamedQueryAsResultContext func(ctx context.Context, sql string, params any) QueryResult + NamedQueryRow func(sql string, data any) (map[string]interface{}, error) + PW func() string + Query func(sql string, args ...interface{}) ([]map[string]interface{}, error) + QueryRow func(sql string, args ...interface{}) (map[string]interface{}, error) + Replace func(tableName string, data map[string]any, cc ...QueryOption) (int64, error) + ReplaceContext func(ctx context.Context, tableName string, data map[string]any, cc ...QueryOption) (int64, error) + Select func(dest interface{}, query string, args ...interface{}) error + Upsert func(tableName string, data map[string]any, cc ...QueryOption) (int64, error) + UpsertContext func(ctx context.Context, tableName string, data map[string]any, cc ...QueryOption) (int64, error) + WithTransaction func(fn func(tx DatabaseClient) error) error + WithTransactionContext func(ctx context.Context, fn func(tx DatabaseClient) error) (err error) + type DeleteClause interface + TargetCount func() int + type ExecOption func(*ExecParams) + type ExecParams struct + AutoIncPK string + Ctx context.Context + Params map[string]any + type ExistsCondition struct + Not bool + Query SQLStmt + type Expression interface + type FieldData interface + GetFieldName func() string + GetFieldSize func() int + GetFieldType func() StandardFieldType + GetIndex func() int + GetOrginalDataType func() string + GetValue func() any + IsPrimary func() bool + type Flavor = sqlbuilder.Flavor + type ForeignKeyAction string + const FKActionCascade + const FKActionRestrict + const FKActionSetNull + func ForeignKeyActionFromSQL(s string) (ForeignKeyAction, error) + func (a ForeignKeyAction) String() string + type ForeignKeyInfo interface + GetOnDelete func() ForeignKeyAction + GetOnUpdate func() ForeignKeyAction + GetRefColumn func() string + GetRefTable func() string + type FromClause interface + GetAlias func() string + GetTableName func() string + JoinCount func() int + type FunctionExpr struct + Alias string + Args []Expression + Distinct bool + Name string + func (f *FunctionExpr) As(alias string) *FunctionExpr + type InCondition struct + Left Expression + Not bool + SubQuery SQLStmt + Values []Expression + type InsertClause interface + ColumnCount func() int + GetConflictValue func(name string) (Expression, bool) + GetTargetName func() string + GetValue func(name string) (Expression, bool) + HasColumn func(name string) bool + HasConflictAssignment func(name string) bool + RowCount func() int + type ItemTransformFunc func(item map[string]any) error + type Kind string + const Check + const Default + const ForeignKey + const NotNull + const PrimaryKey + const Unique + type LikePatternExpr struct + Escape string + Pattern string + type LikePatternType int + const Contains + const EndsWith + const Escape + const None + const StartsWith + type LimitClause struct + Limit Expression + Offset Expression + type LiteralExpr struct + Alias string + Value any + func (l *LiteralExpr) As(alias string) *LiteralExpr + type NullCondition struct + Expr Expression + Not bool + type OrderClause struct + Direction string + Expr Expression + Nulls string + type ParameterExpr struct + Alias string + Name string + func (p *ParameterExpr) As(alias string) *ParameterExpr + type PoolConfig struct + ConnMaxIdleTime int + ConnMaxLifetime int + MaxIdleConns int + MaxOpenConns int + type QueryMetadata struct + Args []any + ExecutionTime time.Duration + QueryHash string + RowsAffected int64 + SQL string + type QueryOption func(SQLStmt) SQLStmt + type QueryResult interface + Bool func(columnName string) (bool, error) + Count func() int + Err func() error + Float64 func(columnName string) (float64, error) + GetColumn func(columnName string) ([]any, error) + GetColumns func(columnNames ...string) (map[string][]any, error) + GetFirstRow func() ([]any, []string, error) + GetMetaData func() QueryMetadata + GetPage func() int + GetPageSize func() int + GetRow func(rowIndex int) ([]any, []string, error) + GetTotalCount func() int64 + GetValue func(columnName string, rowIndex ...int) (any, error) + HasError func() bool + Int64 func(columnName string) (int64, error) + IsEmpty func() bool + RawData func() ([][]any, []string, error) + ScanInto func(dest any, opts ...cystructmap.Option) error + ScanIntoEx func(dest any, transform ItemTransformFunc, opts ...cystructmap.Option) error + ScanValue func(dest any, columnName string, rowIndex ...int) error + SetPage func(page int) + SetPageSize func(size int) + SetTotalCount func(total int64) + String func(columnName string) (string, error) + ToMap func() (map[string]any, error) + ToMaps func() ([]map[string]any, error) + type QueryType string + const QueryTypeDelete + const QueryTypeInsert + const QueryTypeSelect + const QueryTypeUnknown + const QueryTypeUpdate + type RawCondition struct + Args []any + SQL string + type RawExpr struct + Alias string + Args []any + SQL string + func (r *RawExpr) As(alias string) *RawExpr + type RowData interface + AsObject func() (map[string]any, error) + ForEach func(fn func(i int, d FieldData) error) error + GetDatabase func() string + GetFieldDatas func() ([]FieldData, error) + GetFields func() ([]string, error) + GetReplaceSql func() (string, error) + GetSchema func() string + GetTableName func() string + GetValues func() ([]any, []string, error) + GetValuesSkipPK func() ([]any, []string, error) + IsEmpty func() bool + type SQLImpact struct + AffectedTables []string + EstimatedRows *int64 + SQLType string + ScanType string + UseIndex bool + type SQLStmt interface + Apply func(opts ...QueryOption) SQLStmt + Avg func(executor DBExecutor, target any, opts ...ExecOption) (float64, error) + Build func(flavor Flavor) (string, []interface{}, error) + BuildMySQL func() (string, []interface{}, error) + BuildNamedSQL func(opts BuildOptions) (string, map[string]any, error) + BuildPostgreSQL func() (string, []interface{}, error) + BuildSQL func(opts BuildOptions) (string, []interface{}, error) + BuildSQLite func() (string, []interface{}, error) + BuildWhereNamedSQL func(opts BuildOptions) (string, map[string]any, error) + BuildWhereSQL func(opts BuildOptions) (string, []interface{}, error) + Clone func() SQLStmt + Columns func(cols ...any) SQLStmt + ColumnsIfNotSet func(cols ...any) SQLStmt + Count func(executor DBExecutor, target any, opts ...ExecOption) (int64, error) + CrossJoin func(target any, alias ...string) SQLStmt + Delete func(table string) SQLStmt + Distinct func() SQLStmt + Exec func(executor DBExecutor, opts ...ExecOption) (int64, error) + ForShare func() SQLStmt + ForUpdate func() SQLStmt + From func(table any, alias ...string) SQLStmt + FullJoin func(target any, args ...any) SQLStmt + GetCTEs func() []*CommonTableExpr + GetFromClause func() FromClause + GetGroupByItems func() []Expression + GetHavingCond func() Condition + GetInsertClause func() InsertClause + GetLimitClause func() *LimitClause + GetOrderByItems func() []OrderClause + GetSelectClause func() SelectClause + GetSetFields func() []string + GetTableName func() string + GetType func() QueryType + GetUnions func() []UnionClause + GetUpdateClause func() UpdateClause + GetWhereCond func() Condition + GroupBy func(args ...any) SQLStmt + HasColumns func() bool + HasSetField func(name string) bool + HasWhere func() bool + Having func(cond any) SQLStmt + Insert func(table any) SQLStmt + InsertAndGetID func(executor DBExecutor, opts ...ExecOption) (int64, error) + Join func(target any, args ...any) SQLStmt + JoinOn func(tableWithAlias string, on string) SQLStmt + LeftJoin func(target any, args ...any) SQLStmt + LeftJoinOn func(tableWithAlias string, on string) SQLStmt + Limit func(n int) SQLStmt + Offset func(n int) SQLStmt + OnConflict func(assignments ...any) SQLStmt + OnConflictUpdate func(col string, value any) SQLStmt + OrderBy func(args ...any) SQLStmt + OrderByAsc func(cols ...any) SQLStmt + OrderByDesc func(cols ...any) SQLStmt + Page func(page, pageSize int) SQLStmt + Query func(executor DBExecutor, dest any, opts ...ExecOption) error + QueryAsResult func(executor DBExecutor, opts ...ExecOption) QueryResult + QueryForEach func(executor DBExecutor, fn func(RowData) error, opts ...ExecOption) error + QueryOneRow func(executor DBExecutor, opts ...ExecOption) ([]any, []string, error) + QueryPagedResult func(executor DBExecutor, opts ...ExecOption) QueryResult + RightJoin func(target any, args ...any) SQLStmt + RightJoinOn func(tableWithAlias string, on string) SQLStmt + Select func(args ...any) SQLStmt + SelectIfEmpty func(args ...any) SQLStmt + Set func(assignments ...any) SQLStmt + SetLimitClause func(c *LimitClause) + SetOrderByItems func(items []OrderClause) + SetValue func(col string, value any) SQLStmt + Sum func(executor DBExecutor, target any, opts ...ExecOption) (float64, error) + Union func(query SQLStmt) SQLStmt + UnionAll func(query SQLStmt) SQLStmt + Update func(table string) SQLStmt + Values func(values ...any) SQLStmt + Where func(conds ...any) SQLStmt + WhereAll func(conds ...any) SQLStmt + WhereAny func(conds ...any) SQLStmt + WhereBetween func(column string, start, end any) SQLStmt + WhereNotBetween func(column string, start, end any) SQLStmt + WhereOr func(conds ...any) SQLStmt + WhereTupleEQ func(cols []string, vals ...any) SQLStmt + WhereTupleGT func(cols []string, vals ...any) SQLStmt + WhereTupleIN func(cols []string, valsList [][]any) SQLStmt + With func(ctes ...any) SQLStmt + type SelectClause interface + FieldCount func() int + HasField func(name string) bool + IsDistinct func() bool + type StandardFieldType string + const TypeBigint + const TypeBit + const TypeBlob + const TypeBool + const TypeChar + const TypeDate + const TypeDatetime + const TypeDecimal + const TypeDouble + const TypeFloat + const TypeInt + const TypeJSON + const TypeJSONB + const TypeLongtext + const TypeMediumtext + const TypeRawJSON + const TypeSmallint + const TypeText + const TypeTime + const TypeTimestamp + const TypeTinyint + const TypeTinytext + const TypeUbigint + const TypeUint + const TypeUsmallint + const TypeUtinyint + const TypeVarbinary + const TypeVarchar + type SubQueryExpr struct + Alias string + Query SQLStmt + func (s *SubQueryExpr) As(alias string) *SubQueryExpr + type TableConstraint interface + GetColumns func() []string + GetName func() string + GetType func() Kind + type TableInfo interface + ColumnExist func(columnName string) bool + FilterColumns func(columnNames []string, skipPK bool) []string + GetColumn func(idx int) ColumnInfo + GetColumnIndex func(columnName string) int + GetColumns func() []ColumnInfo + GetComment func() string + GetCompositeForeignKeys func() []CompositeForeignKey + GetCompositeIndexes func() []CompositeIndex + GetConstraints func() []TableConstraint + GetDatabase func() string + GetName func() string + GetPrimaryKeys func() []string + GetSchema func() string + GetType func() (string, string) + GetUniqueKeys func() []string + type TupleCondition struct + Left *TupleExpr + Operator string + Right *TupleExpr + type TupleExpr struct + Elements []Expression + type TupleInCondition struct + Left *TupleExpr + Not bool + Values []*TupleExpr + type UnaryExpr struct + Alias string + Expr Expression + Operator string + func (u *UnaryExpr) As(alias string) *UnaryExpr + type UnionClause struct + All bool + Query SQLStmt + type UpdateClause interface + AssignmentCount func() int + GetTargetName func() string + GetValue func(name string) (Expression, bool) + HasAssignment func(name string) bool + type ValidationError struct + Column int + Line int + Message string + Valid bool + func (e *ValidationError) Error() string + type WhenThen struct + Then Expression + When Expression + type WildcardExpr struct + Schema string + Table string + type WindowExpr struct + Alias string + Frame *WindowFrame + Function *FunctionExpr + OrderBy []OrderClause + PartitionBy []Expression + func (w *WindowExpr) As(alias string) *WindowExpr + type WindowFrame struct + End string + Exclude string + Start string + Type string