Documentation ¶
Index ¶
- type ClauseColumn
- func (clauseColumn *ClauseColumn[TYPE]) Assignment(value TYPE) clause.Assignment
- func (clauseColumn *ClauseColumn[TYPE]) Column() clause.Column
- func (clauseColumn *ClauseColumn[TYPE]) WithAlias(alias string) *ClauseColumn[TYPE]
- func (clauseColumn *ClauseColumn[TYPE]) WithRaw(raw bool) *ClauseColumn[TYPE]
- func (clauseColumn *ClauseColumn[TYPE]) WithTable(tableName string) *ClauseColumn[TYPE]
- type CoalesceNonNullGuardian
- func (qs *CoalesceNonNullGuardian) AvgStmt(alias string) string
- func (qs *CoalesceNonNullGuardian) MaxStmt(alias string) string
- func (qs *CoalesceNonNullGuardian) MinStmt(alias string) string
- func (qs *CoalesceNonNullGuardian) Stmt(sfn string, dfv string, alias string) string
- func (qs *CoalesceNonNullGuardian) SumStmt(alias string) string
- type ColumnName
- func (columnName ColumnName[TYPE]) AsAlias(alias string) string
- func (columnName ColumnName[TYPE]) BetweenAND(arg1, arg2 TYPE) (string, TYPE, TYPE)
- func (columnName ColumnName[TYPE]) BetweenAnd(arg1, arg2 TYPE) (string, TYPE, TYPE)
- func (columnName ColumnName[TYPE]) COALESCE() *CoalesceNonNullGuardian
- func (columnName ColumnName[TYPE]) Clause() *ClauseColumn[TYPE]
- func (columnName ColumnName[TYPE]) ClauseWithTable(tableName string) *ClauseColumn[TYPE]
- func (columnName ColumnName[TYPE]) ColumnCondition(op string) QsConjunction
- func (columnName ColumnName[TYPE]) ColumnConditionWithValue(op string, x TYPE) *QxConjunction
- func (columnName ColumnName[TYPE]) ColumnKeyAndValue(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) Count(alias string) string
- func (columnName ColumnName[TYPE]) CountDistinct(alias string) string
- func (columnName ColumnName[TYPE]) CreateColumnValueMap(x TYPE) ColumnValueMap
- func (columnName ColumnName[TYPE]) Eq(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) ExprAdd(v TYPE) clause.Expr
- func (columnName ColumnName[TYPE]) ExprSub(v TYPE) clause.Expr
- func (columnName ColumnName[TYPE]) Gt(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) Gte(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) IFNULLFN() *CoalesceNonNullGuardian
- func (columnName ColumnName[TYPE]) In(x []TYPE) (string, []TYPE)
- func (columnName ColumnName[TYPE]) IsFALSE() string
- func (columnName ColumnName[TYPE]) IsFalse() string
- func (columnName ColumnName[TYPE]) IsNULL() string
- func (columnName ColumnName[TYPE]) IsNotNULL() string
- func (columnName ColumnName[TYPE]) IsNotNull() string
- func (columnName ColumnName[TYPE]) IsNull() string
- func (columnName ColumnName[TYPE]) IsTRUE() string
- func (columnName ColumnName[TYPE]) IsTrue() string
- func (columnName ColumnName[TYPE]) KeAdd(x TYPE) (string, clause.Expr)
- func (columnName ColumnName[TYPE]) KeExp(x clause.Expr) (string, clause.Expr)
- func (columnName ColumnName[TYPE]) KeSub(x TYPE) (string, clause.Expr)
- func (columnName ColumnName[TYPE]) Kv(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) Kw(x TYPE) ColumnValueMap
- func (columnName ColumnName[TYPE]) Like(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) Lt(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) Lte(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) Name() string
- func (columnName ColumnName[TYPE]) Ne(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) NotEq(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) NotIn(x []TYPE) (string, []TYPE)
- func (columnName ColumnName[TYPE]) NotLike(x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) Ob(direction string) OrderByBottle
- func (columnName ColumnName[TYPE]) Op(op string, x TYPE) (string, TYPE)
- func (columnName ColumnName[TYPE]) OrderByDirection(direction string) OrderByBottle
- func (columnName ColumnName[TYPE]) Qc(op string) QsConjunction
- func (columnName ColumnName[TYPE]) Qs(op string) string
- func (columnName ColumnName[TYPE]) Qx(op string, x TYPE) *QxConjunction
- func (columnName ColumnName[TYPE]) RawName() string
- func (columnName ColumnName[TYPE]) SafeCnm(quote string) ColumnName[TYPE]
- func (columnName ColumnName[TYPE]) TB(tab utils.GormTableNameFace) *TableColumn[TYPE]
- func (columnName ColumnName[TYPE]) TC(tab utils.GormTableNameFace) *TableColumn[TYPE]
- func (columnName ColumnName[TYPE]) TN(tableName string) *TableColumn[TYPE]
- func (columnName ColumnName[TYPE]) WithTable(tab utils.GormTableNameFace) *TableColumn[TYPE]
- func (columnName ColumnName[TYPE]) WithTableName(tableName string) *TableColumn[TYPE]
- type ColumnOperationClass
- func (common *ColumnOperationClass) CROSSJOIN(tableName string) *TableJoin
- func (common *ColumnOperationClass) CombineColumnNames(a ...utils.ColumnNameInterface) string
- func (common *ColumnOperationClass) CombineSelectStatements(cs ...SelectStatement) *SelectStatement
- func (common *ColumnOperationClass) CombineStatements(a ...string) string
- func (common *ColumnOperationClass) CombineSxs(cs ...SelectStatement) *SelectStatement
- func (common *ColumnOperationClass) CountCaseWhenQxSx(qx *QxConjunction, alias string) *SelectStatement
- func (common *ColumnOperationClass) CountCaseWhenStmt(condition string, alias string) string
- func (common *ColumnOperationClass) CountStmt(alias string) string
- func (common *ColumnOperationClass) CreateColumnValueMap(columnName string, value interface{}) ColumnValueMap
- func (common *ColumnOperationClass) CreateCondition(stmt string, args ...interface{}) *QxConjunction
- func (common *ColumnOperationClass) CreateSelect(stmt string, args ...interface{}) *SelectStatement
- func (common *ColumnOperationClass) INNERJOIN(tableName string) *TableJoin
- func (common *ColumnOperationClass) Kw(columnName string, value interface{}) ColumnValueMap
- func (common *ColumnOperationClass) LEFTJOIN(tableName string) *TableJoin
- func (common *ColumnOperationClass) MergeNames(a ...utils.ColumnNameInterface) string
- func (common *ColumnOperationClass) MergeStmts(a ...string) string
- func (common *ColumnOperationClass) NewColumnValueMap() ColumnValueMap
- func (common *ColumnOperationClass) NewKw() ColumnValueMap
- func (common *ColumnOperationClass) NewQx(stmt string, args ...interface{}) *QxConjunction
- func (common *ColumnOperationClass) NewSx(stmt string, args ...interface{}) *SelectStatement
- func (common *ColumnOperationClass) OK() bool
- func (common *ColumnOperationClass) OrderByColumns(db *gorm.DB, obs ...OrderByBottle) *gorm.DB
- func (common *ColumnOperationClass) Qx(stmt string, args ...interface{}) *QxConjunction
- func (common *ColumnOperationClass) RIGHTJOIN(tableName string) *TableJoin
- func (common *ColumnOperationClass) Select(db *gorm.DB, qxs ...*SelectStatement) *gorm.DB
- func (common *ColumnOperationClass) Sx(stmt string, args ...interface{}) *SelectStatement
- func (common *ColumnOperationClass) UpdateColumns(db *gorm.DB, kws ...ColumnValueMap) *gorm.DB
- func (common *ColumnOperationClass) Where(db *gorm.DB, qxs ...*QxConjunction) *gorm.DB
- type ColumnValueMap
- func (mp ColumnValueMap) AsMap() map[string]interface{}
- func (mp ColumnValueMap) Kw(columnName string, value interface{}) ColumnValueMap
- func (mp ColumnValueMap) Kws() map[string]interface{}
- func (mp ColumnValueMap) Map() map[string]interface{}
- func (mp ColumnValueMap) ToMap() map[string]interface{}
- type OrderByBottle
- type QsConjunction
- func (qsConjunction QsConjunction) AND(qcs ...QsConjunction) QsConjunction
- func (qsConjunction QsConjunction) NOT() QsConjunction
- func (qsConjunction QsConjunction) OR(qcs ...QsConjunction) QsConjunction
- func (qsConjunction QsConjunction) Qs() string
- func (qsConjunction QsConjunction) Qx() *QxConjunction
- func (qsConjunction QsConjunction) Value() (driver.Value, error)
- type QsType
- type QxConjunction
- func (qx *QxConjunction) AND(cs ...*QxConjunction) *QxConjunction
- func (qx *QxConjunction) AND1(stmt string, args ...interface{}) *QxConjunction
- func (qx QxConjunction) Args() []interface{}
- func (qx *QxConjunction) NOT() *QxConjunction
- func (qx *QxConjunction) OR(cs ...*QxConjunction) *QxConjunction
- func (qx *QxConjunction) OR1(stmt string, args ...interface{}) *QxConjunction
- func (qx QxConjunction) Qs() string
- func (qx QxConjunction) Qx0() string
- func (qx QxConjunction) Qx1() (string, interface{})
- func (qx QxConjunction) Qx10() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx QxConjunction) Qx11() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx QxConjunction) Qx12() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx QxConjunction) Qx2() (string, interface{}, interface{})
- func (qx QxConjunction) Qx3() (string, interface{}, interface{}, interface{})
- func (qx QxConjunction) Qx4() (string, interface{}, interface{}, interface{}, interface{})
- func (qx QxConjunction) Qx5() (string, interface{}, interface{}, interface{}, interface{}, interface{})
- func (qx QxConjunction) Qx6() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx QxConjunction) Qx7() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx QxConjunction) Qx8() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx QxConjunction) Qx9() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx QxConjunction) Value() (driver.Value, error)
- type QxType
- type SelectStatement
- func (qx SelectStatement) Args() []interface{}
- func (selectStatement *SelectStatement) Combine(cs ...*SelectStatement) *SelectStatement
- func (qx SelectStatement) Qs() string
- func (qx SelectStatement) Qx0() string
- func (qx SelectStatement) Qx1() (string, interface{})
- func (qx SelectStatement) Qx10() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx SelectStatement) Qx11() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx SelectStatement) Qx12() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx SelectStatement) Qx2() (string, interface{}, interface{})
- func (qx SelectStatement) Qx3() (string, interface{}, interface{}, interface{})
- func (qx SelectStatement) Qx4() (string, interface{}, interface{}, interface{}, interface{})
- func (qx SelectStatement) Qx5() (string, interface{}, interface{}, interface{}, interface{}, interface{})
- func (qx SelectStatement) Qx6() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx SelectStatement) Qx7() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx SelectStatement) Qx8() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx SelectStatement) Qx9() (string, interface{}, interface{}, interface{}, interface{}, interface{}, ...)
- func (qx SelectStatement) Value() (driver.Value, error)
- type SxType
- type TableColumn
- func (tc *TableColumn[TYPE]) AsAlias(alias string) string
- func (tc *TableColumn[TYPE]) AsName(alias ColumnName[TYPE]) string
- func (tc *TableColumn[TYPE]) Cnm() ColumnName[TYPE]
- func (tc *TableColumn[TYPE]) ColumnName() ColumnName[TYPE]
- func (tc *TableColumn[TYPE]) Eq(xc *TableColumn[TYPE]) string
- func (tc *TableColumn[TYPE]) Name() string
- func (tc *TableColumn[TYPE]) Ob(direction string) OrderByBottle
- func (tc *TableColumn[TYPE]) Op(op string, xc *TableColumn[TYPE]) string
- type TableJoin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClauseColumn ¶
ClauseColumn represents a column with additional properties such as table, alias, and raw flag. ClauseColumn 表示一个具有额外属性(如表名、别名和 raw 标志)的列。
func (*ClauseColumn[TYPE]) Assignment ¶
func (clauseColumn *ClauseColumn[TYPE]) Assignment(value TYPE) clause.Assignment
Assignment returns a GORM clause.Assignment, which is used to assign a value to a column. Assignment 返回一个 GORM 的 clause.Assignment,用于将值赋给列。
func (*ClauseColumn[TYPE]) Column ¶
func (clauseColumn *ClauseColumn[TYPE]) Column() clause.Column
Column returns a GORM clause.Column, which represents a column in a SQL statement. Column 返回一个 GORM 的 clause.Column,表示 SQL 语句中的一个列。
func (*ClauseColumn[TYPE]) WithAlias ¶
func (clauseColumn *ClauseColumn[TYPE]) WithAlias(alias string) *ClauseColumn[TYPE]
WithAlias sets the alias for the ClauseColumn and returns the updated ClauseColumn. WithAlias 为 ClauseColumn 设置别名并返回更新后的 ClauseColumn。
func (*ClauseColumn[TYPE]) WithRaw ¶
func (clauseColumn *ClauseColumn[TYPE]) WithRaw(raw bool) *ClauseColumn[TYPE]
WithRaw sets the raw flag for the ClauseColumn and returns the updated ClauseColumn. WithRaw 为 ClauseColumn 设置 raw 标志并返回更新后的 ClauseColumn。
func (*ClauseColumn[TYPE]) WithTable ¶
func (clauseColumn *ClauseColumn[TYPE]) WithTable(tableName string) *ClauseColumn[TYPE]
WithTable sets the table name for the ClauseColumn and returns the updated ClauseColumn. WithTable 为 ClauseColumn 设置表名并返回更新后的 ClauseColumn。
type CoalesceNonNullGuardian ¶
type CoalesceNonNullGuardian struct {
// contains filtered or unexported fields
}
func NewCoalesceNonNullGuardian ¶
func NewCoalesceNonNullGuardian(methodName string, columnName string) *CoalesceNonNullGuardian
func (*CoalesceNonNullGuardian) AvgStmt ¶
func (qs *CoalesceNonNullGuardian) AvgStmt(alias string) string
AvgStmt generates a SQL statement to calculate the average value of the column, using 0 as the default value. AvgStmt 生成一个 SQL 语句,计算列的平均值,默认值为 0。
func (*CoalesceNonNullGuardian) MaxStmt ¶
func (qs *CoalesceNonNullGuardian) MaxStmt(alias string) string
MaxStmt generates a SQL statement to retrieve the maximum value of the column, using 0 as the default value. MaxStmt 生成一个 SQL 语句,检索列的最大值,默认值为 0。
func (*CoalesceNonNullGuardian) MinStmt ¶
func (qs *CoalesceNonNullGuardian) MinStmt(alias string) string
MinStmt generates a SQL statement to retrieve the minimum value of the column, using 0 as the default value. MinStmt 生成一个 SQL 语句,检索列的最小值,默认值为 0。
func (*CoalesceNonNullGuardian) Stmt ¶
func (qs *CoalesceNonNullGuardian) Stmt(sfn string, dfv string, alias string) string
Stmt generates a SQL statement for the COALESCE or IFNULL function with the given function and default value. Stmt 生成一个 SQL 语句,包含 COALESCE 或 IFNULL 函数,并指定默认值。
func (*CoalesceNonNullGuardian) SumStmt ¶
func (qs *CoalesceNonNullGuardian) SumStmt(alias string) string
SumStmt generates a SQL statement to calculate the sum of the column, using 0 as the default value. SumStmt 生成一个 SQL 语句,计算列的总和,默认值为 0。
type ColumnName ¶
ColumnName represents a generic column name for use in SQL queries ColumnName 表示一个通用的列名 可用于 SQL 查询
func Cnm ¶ added in v1.0.44
func Cnm[T any](v T, name string) ColumnName[T]
func New ¶ added in v1.0.44
func New[T any](name string) ColumnName[T]
func (ColumnName[TYPE]) AsAlias ¶
func (columnName ColumnName[TYPE]) AsAlias(alias string) string
AsAlias returns the column name with an alias applied. AsAlias 返回带有别名的列名。
func (ColumnName[TYPE]) BetweenAND ¶
func (columnName ColumnName[TYPE]) BetweenAND(arg1, arg2 TYPE) (string, TYPE, TYPE)
BetweenAND creates a SQL statement to check if the column's value is between two given values. BetweenAND 创建一个 SQL 语句来判断列的值是否介于两个给定的值之间。
func (ColumnName[TYPE]) BetweenAnd ¶
func (columnName ColumnName[TYPE]) BetweenAnd(arg1, arg2 TYPE) (string, TYPE, TYPE)
BetweenAnd creates a SQL statement to check if the column's value is between two given values. BetweenAnd 创建一个 SQL 语句来判断列的值是否介于两个给定的值之间。
func (ColumnName[TYPE]) COALESCE ¶
func (columnName ColumnName[TYPE]) COALESCE() *CoalesceNonNullGuardian
func (ColumnName[TYPE]) Clause ¶
func (columnName ColumnName[TYPE]) Clause() *ClauseColumn[TYPE]
Clause creates a ClauseColumn of the ColumnName instance. Clause 给 ColumnName 实例创建一个 ClauseColumn。
func (ColumnName[TYPE]) ClauseWithTable ¶
func (columnName ColumnName[TYPE]) ClauseWithTable(tableName string) *ClauseColumn[TYPE]
ClauseWithTable creates a ClauseColumn with a specified table name. ClauseWithTable 创建一个带有指定表名的 ClauseColumn。
func (ColumnName[TYPE]) ColumnCondition ¶
func (columnName ColumnName[TYPE]) ColumnCondition(op string) QsConjunction
ColumnCondition creates a condition for the column using the provided operator (e.g., '=', '>', etc.). ColumnCondition: 使用提供的运算符(例如 '=', '>', 等)为列创建条件。
func (ColumnName[TYPE]) ColumnConditionWithValue ¶
func (columnName ColumnName[TYPE]) ColumnConditionWithValue(op string, x TYPE) *QxConjunction
ColumnConditionWithValue creates a condition with an operator and a value for the column, useful for building complex queries. ColumnConditionWithValue: 创建带有运算符和值的列条件,用于构建复杂的查询。
func (ColumnName[TYPE]) ColumnKeyAndValue ¶
func (columnName ColumnName[TYPE]) ColumnKeyAndValue(x TYPE) (string, TYPE)
ColumnKeyAndValue returns a key-value, useful for GORM's Update function. ColumnKeyAndValue: 返回键值对,适用于GORM的Update函数。
func (ColumnName[TYPE]) Count ¶
func (columnName ColumnName[TYPE]) Count(alias string) string
Count creates a COUNT query for the column, excluding NULL values. Count: 创建一个COUNT查询,只统计非NULL值的列。
func (ColumnName[TYPE]) CountDistinct ¶
func (columnName ColumnName[TYPE]) CountDistinct(alias string) string
CountDistinct creates a COUNT DISTINCT query for the given column, skipping NULL values in the count. CountDistinct: 创建一个COUNT DISTINCT查询,用于给定列,跳过NULL值。
func (ColumnName[TYPE]) CreateColumnValueMap ¶
func (columnName ColumnName[TYPE]) CreateColumnValueMap(x TYPE) ColumnValueMap
CreateColumnValueMap creates a map with a single key-value. CreateColumnValueMap: 创建一个包含单个键值对的map。
func (ColumnName[TYPE]) Eq ¶
func (columnName ColumnName[TYPE]) Eq(x TYPE) (string, TYPE)
Eq creates a SQL statement to check if the column is equal to a given value. Eq 创建一个 SQL 语句来判断列是否等于给定的值。
func (ColumnName[TYPE]) ExprAdd ¶
func (columnName ColumnName[TYPE]) ExprAdd(v TYPE) clause.Expr
ExprAdd creates a GORM expression to add a value to the column. ExprAdd: 创建一个GORM表达式,将一个值加到列中。
func (ColumnName[TYPE]) ExprSub ¶
func (columnName ColumnName[TYPE]) ExprSub(v TYPE) clause.Expr
ExprSub creates a GORM expression to subtract a value from the column. ExprSub: 创建一个GORM表达式,从列中减去一个值。
func (ColumnName[TYPE]) Gt ¶
func (columnName ColumnName[TYPE]) Gt(x TYPE) (string, TYPE)
Gt creates a SQL statement to check if the column is greater than a given value. Gt 创建一个 SQL 语句来判断列是否大于给定的值。
func (ColumnName[TYPE]) Gte ¶
func (columnName ColumnName[TYPE]) Gte(x TYPE) (string, TYPE)
Gte creates a SQL statement to check if the column is greater than or equal to a given value. Gte 创建一个 SQL 语句来判断列是否大于等于给定的值。
func (ColumnName[TYPE]) IFNULLFN ¶
func (columnName ColumnName[TYPE]) IFNULLFN() *CoalesceNonNullGuardian
func (ColumnName[TYPE]) In ¶
func (columnName ColumnName[TYPE]) In(x []TYPE) (string, []TYPE)
In creates a SQL statement to check if the column's value is in a given list of values. In 创建一个 SQL 语句来判断列的值是否在给定的值列表中。
func (ColumnName[TYPE]) IsFALSE ¶
func (columnName ColumnName[TYPE]) IsFALSE() string
IsFALSE creates a SQL statement to check if the column's value is FALSE. IsFALSE 创建一个 SQL 语句来判断列的值是否为 FALSE。
func (ColumnName[TYPE]) IsFalse ¶
func (columnName ColumnName[TYPE]) IsFalse() string
IsFalse creates a SQL statement to check if the column's value is FALSE. IsFalse 创建一个 SQL 语句来判断列的值是否为 FALSE。
func (ColumnName[TYPE]) IsNULL ¶
func (columnName ColumnName[TYPE]) IsNULL() string
IsNULL creates a SQL statement to check if the column is NULL. IsNULL 创建一个 SQL 语句来判断列是否为 NULL。
func (ColumnName[TYPE]) IsNotNULL ¶
func (columnName ColumnName[TYPE]) IsNotNULL() string
IsNotNULL creates a SQL statement to check if the column is not NULL. IsNotNULL 创建一个 SQL 语句来判断列是否不为 NULL。
func (ColumnName[TYPE]) IsNotNull ¶
func (columnName ColumnName[TYPE]) IsNotNull() string
IsNotNull creates a SQL statement to check if the column is not NULL. IsNotNull 创建一个 SQL 语句来判断列是否不为 NULL。
func (ColumnName[TYPE]) IsNull ¶
func (columnName ColumnName[TYPE]) IsNull() string
IsNull creates a SQL statement to check if the column is NULL. IsNull 创建一个 SQL 语句来判断列是否为 NULL。
func (ColumnName[TYPE]) IsTRUE ¶
func (columnName ColumnName[TYPE]) IsTRUE() string
IsTRUE creates a SQL statement to check if the column's value is TRUE. IsTRUE 创建一个 SQL 语句来判断列的值是否为 TRUE。
func (ColumnName[TYPE]) IsTrue ¶
func (columnName ColumnName[TYPE]) IsTrue() string
IsTrue creates a SQL statement to check if the column's value is TRUE. IsTrue 创建一个 SQL 语句来判断列的值是否为 TRUE。
func (ColumnName[TYPE]) KeAdd ¶
func (columnName ColumnName[TYPE]) KeAdd(x TYPE) (string, clause.Expr)
KeAdd is used for updates where a value is added to the field (e.g., incrementing a value). KeAdd: 用于更新字段时,将一个值加到字段上(例如递增一个值)。
func (ColumnName[TYPE]) KeExp ¶
KeExp extends Kv by returning a key-expression, useful in GORM's Update function with expressions. KeExp: 扩展Kv,返回键表达式对,适用于GORM的Update函数,支持表达式。
func (ColumnName[TYPE]) KeSub ¶
func (columnName ColumnName[TYPE]) KeSub(x TYPE) (string, clause.Expr)
KeSub is used for updates where a value is subtracted from the field (e.g., decrementing a value). KeSub: 用于更新字段时,将一个值从字段中减去(例如递减一个值)。
func (ColumnName[TYPE]) Kv ¶
func (columnName ColumnName[TYPE]) Kv(x TYPE) (string, TYPE)
Kv returns a key-value, works with GORM's Update function. Kv: 返回键值对,适用于GORM的Update函数。
func (ColumnName[TYPE]) Kw ¶
func (columnName ColumnName[TYPE]) Kw(x TYPE) ColumnValueMap
Kw creates a map with a single key-value. Kw: 创建一个包含单个键值对的map。
func (ColumnName[TYPE]) Like ¶
func (columnName ColumnName[TYPE]) Like(x TYPE) (string, TYPE)
Like creates a SQL statement to check if the column's value matches a given pattern. Like 创建一个 SQL 语句来判断列的值是否匹配给定的模式。
func (ColumnName[TYPE]) Lt ¶
func (columnName ColumnName[TYPE]) Lt(x TYPE) (string, TYPE)
Lt creates a SQL statement to check if the column is less than a given value. Lt 创建一个 SQL 语句来判断列是否小于给定的值。
func (ColumnName[TYPE]) Lte ¶
func (columnName ColumnName[TYPE]) Lte(x TYPE) (string, TYPE)
Lte creates a SQL statement to check if the column is less than or equal to a given value. Lte 创建一个 SQL 语句来判断列是否小于等于给定的值。
func (ColumnName[TYPE]) Name ¶
func (columnName ColumnName[TYPE]) Name() string
Name returns the raw column name. Name 返回原始的列名。
func (ColumnName[TYPE]) Ne ¶
func (columnName ColumnName[TYPE]) Ne(x TYPE) (string, TYPE)
Ne creates a SQL statement to check if the column is not equal to a given value. Ne 创建一个 SQL 语句来判断列是否不等于给定的值。
func (ColumnName[TYPE]) NotEq ¶
func (columnName ColumnName[TYPE]) NotEq(x TYPE) (string, TYPE)
NotEq creates a SQL statement to check if the column is not equal to a given value. NotEq 创建一个 SQL 语句来判断列是否不等于给定的值。
func (ColumnName[TYPE]) NotIn ¶
func (columnName ColumnName[TYPE]) NotIn(x []TYPE) (string, []TYPE)
NotIn creates a SQL statement to check if the column's value is not in a given list of values. NotIn 创建一个 SQL 语句来判断列的值是否不在给定的值列表中。
func (ColumnName[TYPE]) NotLike ¶
func (columnName ColumnName[TYPE]) NotLike(x TYPE) (string, TYPE)
NotLike creates a SQL statement to check if the column's value does not match a given pattern. NotLike 创建一个 SQL 语句来判断列的值是否不匹配给定的模式。
func (ColumnName[TYPE]) Ob ¶
func (columnName ColumnName[TYPE]) Ob(direction string) OrderByBottle
Ob creates an order-by clause for the column with the specified direction (ASC or DESC). Ob: 创建一个带有指定方向(ASC或DESC)的ORDER BY子句。
func (ColumnName[TYPE]) Op ¶
func (columnName ColumnName[TYPE]) Op(op string, x TYPE) (string, TYPE)
Op creates a SQL statement with an operator and a parameter. Op 创建一个带有操作符和参数的 SQL 语句。
func (ColumnName[TYPE]) OrderByDirection ¶
func (columnName ColumnName[TYPE]) OrderByDirection(direction string) OrderByBottle
OrderByDirection creates an order-by clause for the column with the given direction (ASC or DESC). OrderByDirection: 创建一个带有给定方向(ASC或DESC)的ORDER BY子句。
func (ColumnName[TYPE]) Qc ¶
func (columnName ColumnName[TYPE]) Qc(op string) QsConjunction
Qc creates a condition for the column using the provided operator (e.g., '=', '>', etc.). Qc: 使用提供的运算符(例如 '=', '>', 等)为列创建条件。
func (ColumnName[TYPE]) Qs ¶
func (columnName ColumnName[TYPE]) Qs(op string) string
Qs creates a SQL statement with a given operator. Qs 创建一个带有指定操作符的 SQL 语句。
func (ColumnName[TYPE]) Qx ¶
func (columnName ColumnName[TYPE]) Qx(op string, x TYPE) *QxConjunction
Qx creates a condition with an operator and a value for the column, useful for building complex queries. Qx: 创建带有运算符和值的条件,用于构建复杂的查询。
func (ColumnName[TYPE]) RawName ¶
func (columnName ColumnName[TYPE]) RawName() string
RawName returns the raw column name. RawName 返回原始的列名。
func (ColumnName[TYPE]) SafeCnm ¶
func (columnName ColumnName[TYPE]) SafeCnm(quote string) ColumnName[TYPE]
SafeCnm returns a safe column name by enclosing it in backticks. SafeCnm 返回一个安全的列名,将其用反引号括起来。 If the column name conflicts with a SQL keyword (e.g., "create"), enclosing it in backticks ensures proper execution. 如果列名与SQL关键字(例如"create")冲突,使用反引号将其括起来,确保正确执行。 This function is useful when using db.Select("`type`").Find(&one) as an example. 该函数在使用 db.Select("`type`").Find(&one) 等查询时非常有用。
func (ColumnName[TYPE]) TB ¶
func (columnName ColumnName[TYPE]) TB(tab utils.GormTableNameFace) *TableColumn[TYPE]
func (ColumnName[TYPE]) TC ¶
func (columnName ColumnName[TYPE]) TC(tab utils.GormTableNameFace) *TableColumn[TYPE]
func (ColumnName[TYPE]) TN ¶
func (columnName ColumnName[TYPE]) TN(tableName string) *TableColumn[TYPE]
func (ColumnName[TYPE]) WithTable ¶
func (columnName ColumnName[TYPE]) WithTable(tab utils.GormTableNameFace) *TableColumn[TYPE]
func (ColumnName[TYPE]) WithTableName ¶
func (columnName ColumnName[TYPE]) WithTableName(tableName string) *TableColumn[TYPE]
type ColumnOperationClass ¶
type ColumnOperationClass struct{}
ColumnOperationClass provides a set of common methods for handling column operations in database queries. ColumnOperationClass 提供一组常用的数据库列操作工具函数。
func (*ColumnOperationClass) CROSSJOIN ¶
func (common *ColumnOperationClass) CROSSJOIN(tableName string) *TableJoin
CROSSJOIN creates a cross join operation for the specified table. CROSSJOIN 给指定表创建一个交叉连接操作。
func (*ColumnOperationClass) CombineColumnNames ¶
func (common *ColumnOperationClass) CombineColumnNames(a ...utils.ColumnNameInterface) string
CombineColumnNames combines the names of the provided ColumnNameInterfaces into a single string. CombineColumnNames 将提供的ColumnNameInterface的名称组合成一个字符串。
func (*ColumnOperationClass) CombineSelectStatements ¶
func (common *ColumnOperationClass) CombineSelectStatements(cs ...SelectStatement) *SelectStatement
CombineSelectStatements combines multiple SelectStatements into a single SelectStatement. CombineSelectStatements 将多个SelectStatement组合成一个SelectStatement。
func (*ColumnOperationClass) CombineStatements ¶
func (common *ColumnOperationClass) CombineStatements(a ...string) string
CombineStatements combines the provided SQL statements into a single string. CombineStatements 将提供的SQL语句组合成一个字符串。
func (*ColumnOperationClass) CombineSxs ¶
func (common *ColumnOperationClass) CombineSxs(cs ...SelectStatement) *SelectStatement
CombineSxs combines multiple SelectStatements into a single SelectStatement. CombineSxs 将多个SelectStatement组合成一个SelectStatement。
func (*ColumnOperationClass) CountCaseWhenQxSx ¶
func (common *ColumnOperationClass) CountCaseWhenQxSx(qx *QxConjunction, alias string) *SelectStatement
CountCaseWhenQxSx returns a SelectStatement with a COUNT CASE WHEN condition applied, using the provided QxConjunction and alias. CountCaseWhenQxSx 返回一个带有COUNT CASE WHEN条件的SelectStatement,使用提供的QxConjunction和别名。
func (*ColumnOperationClass) CountCaseWhenStmt ¶
func (common *ColumnOperationClass) CountCaseWhenStmt(condition string, alias string) string
CountCaseWhenStmt returns a SQL statement that counts the records with a CASE WHEN condition, applying the alias. CountCaseWhenStmt 返回一个计算记录数量的SQL语句,带有CASE WHEN条件,并应用别名。
func (*ColumnOperationClass) CountStmt ¶
func (common *ColumnOperationClass) CountStmt(alias string) string
CountStmt returns a SQL statement that counts the records, applying the alias. CountStmt 返回一个计算记录数量的SQL语句,并应用别名。
func (*ColumnOperationClass) CreateColumnValueMap ¶
func (common *ColumnOperationClass) CreateColumnValueMap(columnName string, value interface{}) ColumnValueMap
CreateColumnValueMap creates a ColumnValueMap using the provided column name and value. CreateColumnValueMap 根据提供的列名和值创建一个ColumnValueMap。
func (*ColumnOperationClass) CreateCondition ¶
func (common *ColumnOperationClass) CreateCondition(stmt string, args ...interface{}) *QxConjunction
CreateCondition creates a new QxConjunction with the provided statement and arguments. CreateCondition 根据提供的语句和参数创建一个新的QxConjunction。
func (*ColumnOperationClass) CreateSelect ¶
func (common *ColumnOperationClass) CreateSelect(stmt string, args ...interface{}) *SelectStatement
CreateSelect creates a new SelectStatement with the provided statement and arguments. CreateSelect 根据提供的语句和参数创建一个新的SelectStatement。
func (*ColumnOperationClass) INNERJOIN ¶
func (common *ColumnOperationClass) INNERJOIN(tableName string) *TableJoin
INNERJOIN creates an inner join operation for the specified table. INNERJOIN 给指定表创建一个内连接操作。
func (*ColumnOperationClass) Kw ¶
func (common *ColumnOperationClass) Kw(columnName string, value interface{}) ColumnValueMap
Kw creates a ColumnValueMap using the provided column name and value. Kw 根据提供的列名和值创建一个ColumnValueMap。
func (*ColumnOperationClass) LEFTJOIN ¶
func (common *ColumnOperationClass) LEFTJOIN(tableName string) *TableJoin
LEFTJOIN creates a left join operation for the specified table. LEFTJOIN 给指定表创建一个左连接操作。
func (*ColumnOperationClass) MergeNames ¶
func (common *ColumnOperationClass) MergeNames(a ...utils.ColumnNameInterface) string
MergeNames combines the names of the provided ColumnNameInterfaces into a single string. MergeNames 将提供的ColumnNameInterface的名称组合成一个字符串。
func (*ColumnOperationClass) MergeStmts ¶
func (common *ColumnOperationClass) MergeStmts(a ...string) string
MergeStmts combines the provided SQL statements into a single string. MergeStmts 将提供的SQL语句组合成一个字符串。
func (*ColumnOperationClass) NewColumnValueMap ¶
func (common *ColumnOperationClass) NewColumnValueMap() ColumnValueMap
NewColumnValueMap creates a new ColumnValueMap using the NewKw function. NewColumnValueMap 使用NewKw函数创建一个新的ColumnValueMap。
func (*ColumnOperationClass) NewKw ¶
func (common *ColumnOperationClass) NewKw() ColumnValueMap
NewKw creates a new ColumnValueMap using the Kw function. NewKw 使用Kw函数创建一个新的ColumnValueMap。
func (*ColumnOperationClass) NewQx ¶
func (common *ColumnOperationClass) NewQx(stmt string, args ...interface{}) *QxConjunction
NewQx creates a new QxConjunction with the provided statement and arguments. NewQx 根据提供的语句和参数创建一个新的QxConjunction。
func (*ColumnOperationClass) NewSx ¶
func (common *ColumnOperationClass) NewSx(stmt string, args ...interface{}) *SelectStatement
NewSx creates a new SelectStatement with the provided statement and arguments. NewSx 根据提供的语句和参数创建一个新的SelectStatement。
func (*ColumnOperationClass) OK ¶
func (common *ColumnOperationClass) OK() bool
OK always returns true and provides a simple boolean condition. Its primary purpose is to offer a compact scope in which variables are valid only within the conditional block. This helps improve code clarity by limiting the scope of variables and making the logic easier to follow. OK 函数始终返回true,提供一个简单的布尔条件供控制流使用。 它的主要目的是提供一个小的作用域,在这个作用域内定义的变量只在条件块内有效。 这种做法有助于提高代码的清晰度,通过限制变量的作用域, 使得逻辑更加清晰和易于理解。
func (*ColumnOperationClass) OrderByColumns ¶
func (common *ColumnOperationClass) OrderByColumns(db *gorm.DB, obs ...OrderByBottle) *gorm.DB
OrderByColumns applies the provided OrderByBottle objects to the given gorm.DB statement. OrderByColumns 将提供的OrderByBottle对象应用到给定的gorm.DB语句。
func (*ColumnOperationClass) Qx ¶
func (common *ColumnOperationClass) Qx(stmt string, args ...interface{}) *QxConjunction
Qx returns a new QxConjunction with the provided statement and arguments. Qx 返回一个新的QxConjunction,使用提供的语句和参数。
func (*ColumnOperationClass) RIGHTJOIN ¶
func (common *ColumnOperationClass) RIGHTJOIN(tableName string) *TableJoin
RIGHTJOIN creates a right join operation for the specified table. RIGHTJOIN 给指定表创建一个右连接操作。
func (*ColumnOperationClass) Select ¶
func (common *ColumnOperationClass) Select(db *gorm.DB, qxs ...*SelectStatement) *gorm.DB
Select applies the provided SelectStatements to the given gorm.DB statement. Select 将提供的SelectStatement应用到给定的gorm.DB语句。
func (*ColumnOperationClass) Sx ¶
func (common *ColumnOperationClass) Sx(stmt string, args ...interface{}) *SelectStatement
Sx returns a new SelectStatement with the provided statement and arguments. Sx 返回一个新的SelectStatement,使用提供的语句和参数。
func (*ColumnOperationClass) UpdateColumns ¶
func (common *ColumnOperationClass) UpdateColumns(db *gorm.DB, kws ...ColumnValueMap) *gorm.DB
UpdateColumns updates the columns of the given gorm.DB statement with the provided ColumnValueMaps. UpdateColumns 使用提供的ColumnValueMap更新给定的gorm.DB语句的列。
func (*ColumnOperationClass) Where ¶
func (common *ColumnOperationClass) Where(db *gorm.DB, qxs ...*QxConjunction) *gorm.DB
Where applies the provided QxConjunctions to the given gorm.DB statement. Where 将提供的QxConjunction应用到给定的gorm.DB语句。
type ColumnValueMap ¶
type ColumnValueMap map[string]interface{}
ColumnValueMap is a map type used for GORM update logic to represent column-value mappings. ColumnValueMap 是一个用于 GORM 更新逻辑的映射类型,用于表示列与值的对应关系表。
func Kw ¶
func Kw(columnName string, value interface{}) ColumnValueMap
Kw creates a new ColumnValueMap and adds a key-value. Kw 创建一个新的 ColumnValueMap 并添加一个键值对。
func NewKw ¶
func NewKw() ColumnValueMap
NewKw initializes a new ColumnValueMap. NewKw 初始化一个新的 ColumnValueMap。
func (ColumnValueMap) AsMap ¶
func (mp ColumnValueMap) AsMap() map[string]interface{}
AsMap is an alias for converting ColumnValueMap to map[string]interface{}. AsMap 是将 ColumnValueMap 转换为 map[string]interface{} 的别名。
func (ColumnValueMap) Kw ¶
func (mp ColumnValueMap) Kw(columnName string, value interface{}) ColumnValueMap
Kw adds a key-value pair to ColumnValueMap and supports chaining. Kw 向 ColumnValueMap 添加键值对并支持链式调用。
func (ColumnValueMap) Kws ¶
func (mp ColumnValueMap) Kws() map[string]interface{}
Kws converts ColumnValueMap to map[string]interface{} for GORM. Kws 将 ColumnValueMap 转换为 GORM 的 map[string]interface{}。
func (ColumnValueMap) Map ¶
func (mp ColumnValueMap) Map() map[string]interface{}
Map is an alias for converting ColumnValueMap to map[string]interface{}. Map 是将 ColumnValueMap 转换为 map[string]interface{} 的别名。
func (ColumnValueMap) ToMap ¶
func (mp ColumnValueMap) ToMap() map[string]interface{}
ToMap is an alias for converting ColumnValueMap to map[string]interface{}. ToMap 是将 ColumnValueMap 转换为 map[string]interface{} 的别名。
type OrderByBottle ¶
type OrderByBottle string
OrderByBottle represents a sort statement builder, designed with a unique naming style that reflects a materials science focus. OrderByBottle 代表排序语句构建器,使用了与材料学相关的命名风格。
func (OrderByBottle) Ob ¶
func (ob OrderByBottle) Ob(next OrderByBottle) OrderByBottle
Ob concatenates the current OrderByBottle with the next one, forming a combined ordering string. Ob 将当前的 OrderByBottle 与下一个 OrderByBottle 连接,形成一个组合的排序字符串。
func (OrderByBottle) Ox ¶
func (ob OrderByBottle) Ox() string
Ox converts the OrderByBottle to a string. Note that if the type is not specific, it may be ignored by GORM's logic. Ox 将 OrderByBottle 转换为字符串。请注意,如果类型不明确,它可能会被 GORM 的逻辑忽略。 This is an unavoidable limitation due to GORM's handling of the Order field logic. 这是由于 GORM 对 Order 字段逻辑的处理所造成的无法避免的限制。 Users may forget to convert this to a string before passing it to GORM, so it is important to remember this step. 用户可能会忘记在传递给 GORM 之前将其转换为字符串,因此需要记住这一点。 There is currently no elegant solution to this limitation, but it should work fine for personal use. 目前没有优雅的解决方案,但对于个人使用来说应该没有问题。
type QsConjunction ¶
type QsConjunction string
QsConjunction means gorm query statement conjunction. example: OR AND NOT QsConjunction 表示 GORM 查询语句中的连接词,例如 OR、AND、NOT 就是表示 "或"、"且"、"非" 的连接词 在语法学中,conjunction(连词)是一种词类,用来连接词、短语、语句
func NewQsConjunction ¶
func NewQsConjunction(stmt string) QsConjunction
func (QsConjunction) AND ¶
func (qsConjunction QsConjunction) AND(qcs ...QsConjunction) QsConjunction
AND constructs a conjunction using "AND" between QsConjunction instances. AND 使用 "AND" 在多个 QsConjunction 实例之间构造连接语句。
func (QsConjunction) NOT ¶
func (qsConjunction QsConjunction) NOT() QsConjunction
NOT negates the QsConjunction instance by wrapping it with "NOT". NOT 通过添加 "NOT" 来对 QsConjunction 实例进行逻辑取反。
func (QsConjunction) OR ¶
func (qsConjunction QsConjunction) OR(qcs ...QsConjunction) QsConjunction
OR constructs a conjunction using "OR" between QsConjunction instances. OR 使用 "OR" 在多个 QsConjunction 实例之间构造连接语句。
func (QsConjunction) Qs ¶
func (qsConjunction QsConjunction) Qs() string
Qs converts the QsConjunction instance into a string representation. Qs 将 QsConjunction 实例转换为字符串表示。
func (QsConjunction) Qx ¶
func (qsConjunction QsConjunction) Qx() *QxConjunction
Qx converts the QsConjunction instance into a QxConjunction object with arguments. Qx 将 QsConjunction 实例转换为带参数的 QxConjunction 对象。
func (QsConjunction) Value ¶
func (qsConjunction QsConjunction) Value() (driver.Value, error)
Value prevents GORM from directly using QsConjunction by causing a panic. Value 阻止 GORM 直接使用 QsConjunction,通过触发 panic 实现。 当你定义了一个类型为 type xxx string 的自定义类型,并尝试将其用作查询条件时,GORM 会将整个自定义类型作为一个值来处理,而不是将其展开为 SQL 语句中的占位符。 因此也就是说 db.Where(xxx("name = ? AND type = ?")) 这个是不行的 基本的结论是: 当你执行 db.Where(xxx("name = ? AND type = ?")) 时,GORM 会将 xxx("name = ? AND type = ?") 视为一个单独的值,再将其传递给查询条件,而不会将其展开为具体的 SQL 语句。 这时,给 type xxx string 增加 Value 函数,而且里面报panic,就能避免用错 这就是这里给出 Value { panic } 的原因 这样,假如你不把结果转换为string,而是直接往where条件里传递,就会在where条件中触发value异常
type QxConjunction ¶
type QxConjunction struct {
// contains filtered or unexported fields
}
QxConjunction is used for constructing relational query statements (AND, OR, NOT) and their arguments for db.Where. QxConjunction 用于构造关系查询语句(AND、OR、NOT)以及其对应的参数,以供 db.Where 使用。 Example: When combining conditions like a.Eq("xyz") and b.Eq("uvw"), this class concatenates statements with (---) AND (---) and merges arguments into a new list. 示例:当需要组合条件如 a.Eq("xyz") 和 b.Eq("uvw") 时,该工具类将语句用 (---) AND (---) 连接,并将参数列表合并为新的列表。
func NewQxConjunction ¶
func NewQxConjunction(stmt string, args ...interface{}) *QxConjunction
NewQxConjunction creates a new instance of QxConjunction with the provided statement and arguments. NewQxConjunction 使用提供的语句和参数创建一个新的 QxConjunction 实例。
func Qx ¶
func Qx(stmt string, args ...interface{}) *QxConjunction
Qx is a shorthand for creating a new QxConjunction instance. Qx 是创建 QxConjunction 实例的简写形式。
func (*QxConjunction) AND ¶
func (qx *QxConjunction) AND(cs ...*QxConjunction) *QxConjunction
AND combines the current QxConjunction instance with multiple QxConjunction instances using "AND". AND 使用 "AND" 将当前 QxConjunction 实例与多个 QxConjunction 实例组合在一起。
func (*QxConjunction) AND1 ¶
func (qx *QxConjunction) AND1(stmt string, args ...interface{}) *QxConjunction
AND1 creates a new QxConjunction instance with the given statement and arguments, then combines it with the current instance using "AND". AND1 使用给定的语句和参数创建一个新的 QxConjunction 实例,然后使用 "AND" 将其与当前实例组合。
func (QxConjunction) Args ¶
func (qx QxConjunction) Args() []interface{}
Args returns the arguments list of the current statementArgumentsTuple instance. Args 返回当前 statementArgumentsTuple 实例的参数列表。
func (*QxConjunction) NOT ¶
func (qx *QxConjunction) NOT() *QxConjunction
NOT negates the current QxConjunction instance by wrapping the statement with "NOT". NOT 通过在语句外包裹 "NOT" 来对当前 QxConjunction 实例进行逻辑取反。
func (*QxConjunction) OR ¶
func (qx *QxConjunction) OR(cs ...*QxConjunction) *QxConjunction
OR combines the current QxConjunction instance with multiple QxConjunction instances using "OR". OR 使用 "OR" 将当前 QxConjunction 实例与多个 QxConjunction 实例组合在一起。
func (*QxConjunction) OR1 ¶
func (qx *QxConjunction) OR1(stmt string, args ...interface{}) *QxConjunction
OR1 creates a new QxConjunction instance with the given statement and arguments, then combines it with the current instance using "OR". OR1 使用给定的语句和参数创建一个新的 QxConjunction 实例,然后使用 "OR" 将其与当前实例组合。
func (QxConjunction) Qs ¶
func (qx QxConjunction) Qs() string
Qs returns the statement string of the current statementArgumentsTuple instance. Qs 返回当前 statementArgumentsTuple 实例的语句字符串。
func (QxConjunction) Qx0 ¶
func (qx QxConjunction) Qx0() string
Qx0 returns the statement string when there are no arguments in the statementArgumentsTuple instance. Qx0 在 statementArgumentsTuple 实例没有参数时返回语句字符串。
func (QxConjunction) Qx1 ¶
func (qx QxConjunction) Qx1() (string, interface{})
Qx1 returns the statement string and the first argument in the statementArgumentsTuple instance. Qx1 返回 statementArgumentsTuple 实例的语句字符串和第一个参数。
func (QxConjunction) Qx10 ¶
func (qx QxConjunction) Qx10() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (QxConjunction) Qx11 ¶
func (qx QxConjunction) Qx11() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (QxConjunction) Qx12 ¶
func (qx QxConjunction) Qx12() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (QxConjunction) Qx2 ¶
func (qx QxConjunction) Qx2() (string, interface{}, interface{})
Qx2 returns the statement string and the first two arguments in the statementArgumentsTuple instance. Qx2 返回 statementArgumentsTuple 实例的语句字符串和前两个参数。
func (QxConjunction) Qx3 ¶
func (qx QxConjunction) Qx3() (string, interface{}, interface{}, interface{})
Qx3 这块暂时没有什么好的方案,我只能这样罗列下来,很期望将来能够解决这个问题
func (QxConjunction) Qx4 ¶
func (qx QxConjunction) Qx4() (string, interface{}, interface{}, interface{}, interface{})
Qx4 这块暂时没有什么好的方案,我只能这样罗列下来,很期望将来能够解决这个问题
func (QxConjunction) Qx5 ¶
func (qx QxConjunction) Qx5() (string, interface{}, interface{}, interface{}, interface{}, interface{})
func (QxConjunction) Qx6 ¶
func (qx QxConjunction) Qx6() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (QxConjunction) Qx7 ¶
func (qx QxConjunction) Qx7() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (QxConjunction) Qx8 ¶
func (qx QxConjunction) Qx8() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
type QxType ¶
type QxType = QxConjunction
type SelectStatement ¶
type SelectStatement struct {
// contains filtered or unexported fields
}
SelectStatement 就是传给 db.Select 的语句和参数 目前 "选中返回列" 的函数的定义是这样的 func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) 在99%的场景下都是不需要传条件的 但在 SELECT COUNT(CASE WHEN (((name="abc") AND (type="xyz"))) THEN 1 END) as cnt FROM `examples` 这个语句里 很明显的 db.Select 也需要查询语句和参数 "abc" 和 "xyz" 而且这里条件有可能很长,而且有可能 db.Select 选中多个列的数据,就需要合并语句和合并参数 很明显各个列之间是逗号分隔的 因此定义这个类型,主要用来服务于这种场景(其实非常少用)
func NewSelectStatement ¶
func NewSelectStatement(stmt string, args ...interface{}) *SelectStatement
NewSelectStatement creates a new SelectStatement with the provided query string and arguments. NewSelectStatement 使用提供的查询字符串和参数创建一个新的 SelectStatement 实例。
func (SelectStatement) Args ¶
func (qx SelectStatement) Args() []interface{}
Args returns the arguments list of the current statementArgumentsTuple instance. Args 返回当前 statementArgumentsTuple 实例的参数列表。
func (*SelectStatement) Combine ¶
func (selectStatement *SelectStatement) Combine(cs ...*SelectStatement) *SelectStatement
Combine combines the current SelectStatement with other SelectStatements by merging their query strings and arguments. Combine 将当前的 SelectStatement 与其他 SelectStatement 合并,通过合并它们的查询字符串和参数。
func (SelectStatement) Qs ¶
func (qx SelectStatement) Qs() string
Qs returns the statement string of the current statementArgumentsTuple instance. Qs 返回当前 statementArgumentsTuple 实例的语句字符串。
func (SelectStatement) Qx0 ¶
func (qx SelectStatement) Qx0() string
Qx0 returns the statement string when there are no arguments in the statementArgumentsTuple instance. Qx0 在 statementArgumentsTuple 实例没有参数时返回语句字符串。
func (SelectStatement) Qx1 ¶
func (qx SelectStatement) Qx1() (string, interface{})
Qx1 returns the statement string and the first argument in the statementArgumentsTuple instance. Qx1 返回 statementArgumentsTuple 实例的语句字符串和第一个参数。
func (SelectStatement) Qx10 ¶
func (qx SelectStatement) Qx10() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (SelectStatement) Qx11 ¶
func (qx SelectStatement) Qx11() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (SelectStatement) Qx12 ¶
func (qx SelectStatement) Qx12() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (SelectStatement) Qx2 ¶
func (qx SelectStatement) Qx2() (string, interface{}, interface{})
Qx2 returns the statement string and the first two arguments in the statementArgumentsTuple instance. Qx2 返回 statementArgumentsTuple 实例的语句字符串和前两个参数。
func (SelectStatement) Qx3 ¶
func (qx SelectStatement) Qx3() (string, interface{}, interface{}, interface{})
Qx3 这块暂时没有什么好的方案,我只能这样罗列下来,很期望将来能够解决这个问题
func (SelectStatement) Qx4 ¶
func (qx SelectStatement) Qx4() (string, interface{}, interface{}, interface{}, interface{})
Qx4 这块暂时没有什么好的方案,我只能这样罗列下来,很期望将来能够解决这个问题
func (SelectStatement) Qx5 ¶
func (qx SelectStatement) Qx5() (string, interface{}, interface{}, interface{}, interface{}, interface{})
func (SelectStatement) Qx6 ¶
func (qx SelectStatement) Qx6() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (SelectStatement) Qx7 ¶
func (qx SelectStatement) Qx7() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
func (SelectStatement) Qx8 ¶
func (qx SelectStatement) Qx8() (string, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{}, interface{})
type SxType ¶
type SxType = SelectStatement
type TableColumn ¶
type TableColumn[TYPE any] struct { // contains filtered or unexported fields }
TableColumn represents a combination of a table and a column. TableColumn 表示表和列的组合。
func (*TableColumn[TYPE]) AsAlias ¶
func (tc *TableColumn[TYPE]) AsAlias(alias string) string
AsAlias generates a SQL alias for the column in the format "table.column AS alias". AsAlias 生成列的 SQL 别名,格式为 "table.column AS alias"。
func (*TableColumn[TYPE]) AsName ¶
func (tc *TableColumn[TYPE]) AsName(alias ColumnName[TYPE]) string
AsName generates a SQL alias for the column using another ColumnName as the alias. AsName 使用另一个 ColumnName 作为别名生成列的 SQL 别名。
func (*TableColumn[TYPE]) Cnm ¶
func (tc *TableColumn[TYPE]) Cnm() ColumnName[TYPE]
Cnm retrieves the column name in a ColumnName format, representing the combination of the table and column. Cnm 获取以 ColumnName 格式表示的列名,代表表和列的组合。
func (*TableColumn[TYPE]) ColumnName ¶
func (tc *TableColumn[TYPE]) ColumnName() ColumnName[TYPE]
ColumnName retrieves the column name in a ColumnName format, representing the combination of the table and column. ColumnName 获取以 ColumnName 格式表示的列名,代表表和列的组合。
func (*TableColumn[TYPE]) Eq ¶
func (tc *TableColumn[TYPE]) Eq(xc *TableColumn[TYPE]) string
Eq generates an equality condition in SQL format, ensuring type consistency between two columns. Eq 生成 SQL 格式的相等条件,确保两列之间的类型一致。
func (*TableColumn[TYPE]) Name ¶
func (tc *TableColumn[TYPE]) Name() string
Name returns the fully qualified name of the column in the format "table.column". Name 返回列的完全限定名称,格式为 "table.column"。
func (*TableColumn[TYPE]) Ob ¶
func (tc *TableColumn[TYPE]) Ob(direction string) OrderByBottle
Ob creates an OrderByBottle object for specifying ordering based on the column name and direction. Ob 基于列名和方向创建一个 OrderByBottle 对象用于指定排序。
func (*TableColumn[TYPE]) Op ¶
func (tc *TableColumn[TYPE]) Op(op string, xc *TableColumn[TYPE]) string
Op generates a custom SQL operation between two columns using the specified operator. Op 使用指定的操作符生成两列之间的自定义 SQL 操作。