Versions in this module Expand all Collapse all v1 v1.0.2 Apr 13, 2022 Changes in this version type IQueryField + func ADD(name string, fields ...IQueryField) IQueryField + func DIV(name string, fields ...IQueryField) IQueryField + func MUL(name string, fields ...IQueryField) IQueryField + func SUB(name string, fields ...IQueryField) IQueryField v1.0.1 Jan 19, 2022 Changes in this version + const ErrDuplicateEntry + const ErrEmptyPrimaryKey + const ErrEmptyQuery + const ErrNeedsArray + const ErrNeedsPointer + const ErrNoDataToUpdate + const ErrNotSupported + const ErrReadOnly + const ErrTableNotExists + const ErrUnexpectRowCount + const ErrUnionFieldsNotMatch + const SQL_OP_AND + const SQL_OP_BETWEEN + const SQL_OP_EQUAL + const SQL_OP_GE + const SQL_OP_GT + const SQL_OP_IN + const SQL_OP_LE + const SQL_OP_LIKE + const SQL_OP_LT + const SQL_OP_NOT + const SQL_OP_NOTEQUAL + const SQL_OP_NOTIN + const SQL_OP_OR + const TAG_ALLOW_ZERO + const TAG_AUTOINCREMENT + const TAG_AUTOVERSION + const TAG_CHARSET + const TAG_CREATE_TIMESTAMP + const TAG_DEFAULT + const TAG_IGNORE + const TAG_INDEX + const TAG_NAME + const TAG_NULLABLE + const TAG_PRECISION + const TAG_PRIMARY + const TAG_TEXT_LENGTH + const TAG_UNIQUE + const TAG_UPDATE_TIMESTAMP + const TAG_WIDTH + var DEBUG_SQLCHEMY = false + var INT_WIDTH_DEFAULT = map[string]int + var UNSIGNED_INT_WIDTH_DEFAULT = map[string]int + func CloseDB() + func Exec(sql string, args ...interface{}) (sql.Result, error) + func GetDB() *sql.DB + func GetTables() []string + func SetDB(db *sql.DB) + type CompoundColumn struct + func NewCompoundColumn(name string, tagmap map[string]string, isPointer bool) CompoundColumn + func (c *CompoundColumn) ConvertFromValue(val interface{}) interface{} + func (c *CompoundColumn) DefinitionString() string + func (c *CompoundColumn) IsZero(val interface{}) bool + type IColumnSpec interface + AllowZero func() bool + ColType func() string + ConvertFromString func(str string) string + ConvertFromValue func(val interface{}) interface{} + Default func() string + DefinitionString func() string + ExtraDefs func() string + IsAscii func() bool + IsIndex func() bool + IsNullable func() bool + IsNumeric func() bool + IsPointer func() bool + IsPrimary func() bool + IsSearchable func() bool + IsSupportDefault func() bool + IsText func() bool + IsUnique func() bool + IsZero func(val interface{}) bool + Name func() string + SetDefault func(defStr string) + SetNullable func(on bool) + Tags func() map[string]string + type ICondition interface + Variables func() []interface{} + WhereClause func() string + func AND(cond ...ICondition) ICondition + func Between(f IQueryField, r1, r2 interface{}) ICondition + func Contains(f IQueryField, v string) ICondition + func ContainsAny(f IQueryField, v []string) ICondition + func Endswith(f IQueryField, v string) ICondition + func Equals(f IQueryField, v interface{}) ICondition + func GE(f IQueryField, v interface{}) ICondition + func GT(f IQueryField, v interface{}) ICondition + func In(f IQueryField, v interface{}) ICondition + func IsEmpty(f IQueryField) ICondition + func IsFalse(f IQueryField) ICondition + func IsNotEmpty(f IQueryField) ICondition + func IsNotNull(f IQueryField) ICondition + func IsNull(f IQueryField) ICondition + func IsNullOrEmpty(f IQueryField) ICondition + func IsTrue(f IQueryField) ICondition + func LE(f IQueryField, v interface{}) ICondition + func LT(f IQueryField, v interface{}) ICondition + func Like(f IQueryField, v string) ICondition + func NOT(cond ICondition) ICondition + func NoEarlierThan(f IQueryField) ICondition + func NoLaterThan(f IQueryField) ICondition + func NotEquals(f IQueryField, v interface{}) ICondition + func NotIn(f IQueryField, v interface{}) ICondition + func OR(cond ...ICondition) ICondition + func Startswith(f IQueryField, v string) ICondition + type IFunction interface + type IQuery interface + Field func(name string) IQueryField + QueryFields func() []IQueryField + String func(fields ...IQueryField) string + SubQuery func() *SSubQuery + Variables func() []interface{} + type IQueryField interface + Expression func() string + Label func(label string) IQueryField + Name func() string + Reference func() string + Variables func() []interface{} + func AND_Val(name string, field IQueryField, v interface{}) IQueryField + func CONCAT(name string, fields ...IQueryField) IQueryField + func COUNT(name string, field ...IQueryField) IQueryField + func DISTINCT(name string, field IQueryField) IQueryField + func GROUP_CONCAT(name string, field IQueryField) IQueryField + func INET_ATON(field IQueryField) IQueryField + func MAX(name string, field IQueryField) IQueryField + func MIN(name string, field IQueryField) IQueryField + func NewFunction(ifunc IFunction, name string) IQueryField + func NewFunctionField(name string, funcexp string, fields ...IQueryField) IQueryField + func OR_Val(name string, field IQueryField, v interface{}) IQueryField + func REPLACE(name string, field IQueryField, old string, new string) IQueryField + func SUM(name string, field IQueryField) IQueryField + func SubStr(name string, field IQueryField, pos, length int) IQueryField + func TimestampAdd(name string, field IQueryField, offsetSeconds int) IQueryField + type IQuerySource interface + Alias func() string + Expression func() string + Field func(id string, alias ...string) IQueryField + Fields func() []IQueryField + Variables func() []interface{} + type IRowScanner interface + Scan func(desc ...interface{}) error + type ITableSpec interface + AddIndex func(unique bool, cols ...string) bool + ColumnSpec func(name string) IColumnSpec + Columns func() []IColumnSpec + DataType func() reflect.Type + Decrement func(diff, target interface{}) error + DropForeignKeySQL func() []string + Expression func() string + Fetch func(dt interface{}) error + Increment func(diff, target interface{}) error + Insert func(dt interface{}) error + InsertOrUpdate func(dt interface{}) error + Instance func() *STable + Name func() string + PrimaryColumns func() []IColumnSpec + SyncSQL func() []string + Update func(dt interface{}, onUpdate func() error) (UpdateDiffs, error) + type QueryJoinType string + const INNERJOIN + const LEFTJOIN + const RIGHTJOIN + type QueryOrderType string + const SQL_ORDER_ASC + const SQL_ORDER_DESC + func (qot QueryOrderType) Equals(orderType string) bool + type SAndConditions struct + func (c *SAndConditions) WhereClause() string + type SBaseColumn struct + func NewBaseColumn(name string, sqltype string, tagmap map[string]string, isPointer bool) SBaseColumn + func (c *SBaseColumn) AllowZero() bool + func (c *SBaseColumn) ColType() string + func (c *SBaseColumn) ConvertFromString(str string) string + func (c *SBaseColumn) ConvertFromValue(val interface{}) interface{} + func (c *SBaseColumn) Default() string + func (c *SBaseColumn) ExtraDefs() string + func (c *SBaseColumn) IsAscii() bool + func (c *SBaseColumn) IsIndex() bool + func (c *SBaseColumn) IsNullable() bool + func (c *SBaseColumn) IsNumeric() bool + func (c *SBaseColumn) IsPointer() bool + func (c *SBaseColumn) IsPrimary() bool + func (c *SBaseColumn) IsSearchable() bool + func (c *SBaseColumn) IsSupportDefault() bool + func (c *SBaseColumn) IsText() bool + func (c *SBaseColumn) IsUnique() bool + func (c *SBaseColumn) Name() string + func (c *SBaseColumn) SetDefault(defStr string) + func (c *SBaseColumn) SetNullable(on bool) + func (c *SBaseColumn) Tags() map[string]string + type SBaseWidthColumn struct + func NewBaseWidthColumn(name string, sqltype string, tagmap map[string]string, isPointer bool) SBaseWidthColumn + func (c *SBaseWidthColumn) ColType() string + type SBetweenCondition struct + func (t *SBetweenCondition) WhereClause() string + type SBooleanColumn struct + func NewBooleanColumn(name string, tagmap map[string]string, isPointer bool) SBooleanColumn + func (c *SBooleanColumn) ConvertFromString(str string) string + func (c *SBooleanColumn) DefinitionString() string + func (c *SBooleanColumn) IsZero(val interface{}) bool + type SCaseFunction struct + func NewCase() *SCaseFunction + func (cf *SCaseFunction) Else(field IQueryField) *SCaseFunction + func (cf *SCaseFunction) When(when ICondition, then IQueryField) *SCaseFunction + type SCompoundConditions struct + func (c *SCompoundConditions) Variables() []interface{} + func (c *SCompoundConditions) WhereClause() string + type SConstField struct + func NewConstField(variable interface{}) *SConstField + func (s *SConstField) Expression() string + func (s *SConstField) Label(label string) IQueryField + func (s *SConstField) Name() string + func (s *SConstField) Reference() string + func (s *SConstField) Variables() []interface{} + type SDateTimeColumn struct + IsCreatedAt bool + IsUpdatedAt bool + func NewDateTimeColumn(name string, tagmap map[string]string, isPointer bool) SDateTimeColumn + type SDecimalColumn struct + Precision int + func NewDecimalColumn(name string, tagmap map[string]string, isPointer bool) SDecimalColumn + func (c *SDecimalColumn) ColType() string + func (c *SDecimalColumn) DefinitionString() string + func (c *SDecimalColumn) IsNumeric() bool + func (c *SDecimalColumn) IsZero(val interface{}) bool + type SEqualsCondition struct + func (t *SEqualsCondition) WhereClause() string + type SFalseCondition struct + func (t *SFalseCondition) Variables() []interface{} + func (t *SFalseCondition) WhereClause() string + type SFloatColumn struct + func NewFloatColumn(name string, sqlType string, tagmap map[string]string, isPointer bool) SFloatColumn + func (c *SFloatColumn) DefinitionString() string + func (c *SFloatColumn) IsNumeric() bool + func (c *SFloatColumn) IsZero(val interface{}) bool + type SFunctionFieldBase struct + func (ff *SFunctionFieldBase) Expression() string + func (ff *SFunctionFieldBase) Label(label string) IQueryField + func (ff *SFunctionFieldBase) Name() string + func (ff *SFunctionFieldBase) Reference() string + func (ff *SFunctionFieldBase) Variables() []interface{} + type SGreatEqualCondition struct + func (t *SGreatEqualCondition) WhereClause() string + type SGreatThanCondition struct + func (t *SGreatThanCondition) WhereClause() string + type SInCondition struct + func (t *SInCondition) WhereClause() string + type SIntegerColumn struct + AutoIncrementOffset int64 + IsAutoIncrement bool + IsAutoVersion bool + IsUnsigned bool + func NewIntegerColumn(name string, sqltype string, unsigned bool, tagmap map[string]string, ...) SIntegerColumn + func (c *SIntegerColumn) ColType() string + func (c *SIntegerColumn) DefinitionString() string + func (c *SIntegerColumn) ExtraDefs() string + func (c *SIntegerColumn) IsNumeric() bool + func (c *SIntegerColumn) IsZero(val interface{}) bool + type SIsEmptyCondition struct + func (c *SIsEmptyCondition) WhereClause() string + type SIsFalseCondition struct + func (c *SIsFalseCondition) WhereClause() string + type SIsNotEmptyCondition struct + func (c *SIsNotEmptyCondition) WhereClause() string + type SIsNotNullCondition struct + func (c *SIsNotNullCondition) WhereClause() string + type SIsNullCondition struct + func (c *SIsNullCondition) WhereClause() string + type SIsNullOrEmptyCondition struct + func (c *SIsNullOrEmptyCondition) WhereClause() string + type SIsTrueCondition struct + func (c *SIsTrueCondition) WhereClause() string + type SLessEqualCondition struct + func (t *SLessEqualCondition) WhereClause() string + type SLessThanCondition struct + func (t *SLessThanCondition) WhereClause() string + type SLikeCondition struct + func (t *SLikeCondition) WhereClause() string + type SNoEarlierThanCondition struct + func (c *SNoEarlierThanCondition) WhereClause() string + type SNoLaterThanCondition struct + func (c *SNoLaterThanCondition) WhereClause() string + type SNotCondition struct + func (c *SNotCondition) Variables() []interface{} + func (c *SNotCondition) WhereClause() string + type SNotEqualsCondition struct + func (t *SNotEqualsCondition) WhereClause() string + type SOrConditions struct + func (c *SOrConditions) WhereClause() string + type SQuery struct + func DoQuery(from IQuerySource, f ...IQueryField) *SQuery + func NewRawQuery(sqlStr string, fields ...string) *SQuery + func (tq *SQuery) All(dest interface{}) error + func (tq *SQuery) AllStringMap() ([]map[string]string, error) + func (tq *SQuery) AppendField(f ...IQueryField) *SQuery + func (tq *SQuery) Asc(fields ...interface{}) *SQuery + func (tq *SQuery) Between(f string, v1, v2 interface{}) *SQuery + func (tq *SQuery) Contains(f string, v string) *SQuery + func (tq *SQuery) Count() int + func (tq *SQuery) CountWithError() (int, error) + func (tq *SQuery) DebugQuery() + func (tq *SQuery) Desc(fields ...interface{}) *SQuery + func (tq *SQuery) Distinct() *SQuery + func (tq *SQuery) Endswith(f string, v string) *SQuery + func (tq *SQuery) Equals(f string, v interface{}) *SQuery + func (tq *SQuery) Field(name string) IQueryField + func (tq *SQuery) Filter(cond ICondition) *SQuery + func (tq *SQuery) FilterByFalse() *SQuery + func (tq *SQuery) FilterByTrue() *SQuery + func (tq *SQuery) First(dest interface{}) error + func (tq *SQuery) FirstStringMap() (map[string]string, error) + func (tq *SQuery) GE(f string, v interface{}) *SQuery + func (tq *SQuery) GT(f string, v interface{}) *SQuery + func (tq *SQuery) GroupBy(f ...interface{}) *SQuery + func (tq *SQuery) In(f string, v interface{}) *SQuery + func (tq *SQuery) IsAltered() bool + func (tq *SQuery) IsEmpty(f string) *SQuery + func (tq *SQuery) IsFalse(f string) *SQuery + func (tq *SQuery) IsNotEmpty(f string) *SQuery + func (tq *SQuery) IsNotNull(f string) *SQuery + func (tq *SQuery) IsNull(f string) *SQuery + func (tq *SQuery) IsNullOrEmpty(f string) *SQuery + func (tq *SQuery) IsTrue(f string) *SQuery + func (tq *SQuery) Join(from IQuerySource, on ICondition) *SQuery + func (tq *SQuery) LE(f string, v interface{}) *SQuery + func (tq *SQuery) LT(f string, v interface{}) *SQuery + func (tq *SQuery) LeftJoin(from IQuerySource, on ICondition) *SQuery + func (tq *SQuery) Like(f string, v string) *SQuery + func (tq *SQuery) Limit(limit int) *SQuery + func (tq *SQuery) NotBetween(f string, v1, v2 interface{}) *SQuery + func (tq *SQuery) NotEquals(f string, v interface{}) *SQuery + func (tq *SQuery) NotIn(f string, v interface{}) *SQuery + func (tq *SQuery) NotLike(f string, v string) *SQuery + func (tq *SQuery) Offset(offset int) *SQuery + func (tq *SQuery) QueryFields() []IQueryField + func (tq *SQuery) RightJoin(from IQuerySource, on ICondition) *SQuery + func (tq *SQuery) Row() *sql.Row + func (tq *SQuery) Row2Map(row IRowScanner) (map[string]string, error) + func (tq *SQuery) Row2Struct(row IRowScanner, dest interface{}) error + func (tq *SQuery) RowMap2Struct(result map[string]string, dest interface{}) error + func (tq *SQuery) Rows() (*sql.Rows, error) + func (tq *SQuery) Snapshot() *SQuery + func (tq *SQuery) Startswith(f string, v string) *SQuery + func (tq *SQuery) String(fields ...IQueryField) string + func (tq *SQuery) SubQuery() *SSubQuery + func (tq *SQuery) Variables() []interface{} + type SRawQueryField struct + func (rqf *SRawQueryField) Expression() string + func (rqf *SRawQueryField) Label(label string) IQueryField + func (rqf *SRawQueryField) Name() string + func (rqf *SRawQueryField) Reference() string + func (rqf *SRawQueryField) Variables() []interface{} + type SSingleCondition struct + func NewSingleCondition(field IQueryField) SSingleCondition + func (c *SSingleCondition) Variables() []interface{} + type SStringField struct + func NewStringField(name string) *SStringField + func (s *SStringField) Expression() string + func (s *SStringField) Label(label string) IQueryField + func (s *SStringField) Name() string + func (s *SStringField) Reference() string + func (s *SStringField) Variables() []interface{} + type SSubQuery struct + func (sq *SSubQuery) Alias() string + func (sq *SSubQuery) Expression() string + func (sq *SSubQuery) Field(id string, alias ...string) IQueryField + func (sq *SSubQuery) Fields() []IQueryField + func (sq *SSubQuery) Query(f ...IQueryField) *SQuery + func (sq *SSubQuery) Variables() []interface{} + func (sqf *SSubQuery) DebugQuery() + type SSubQueryField struct + func (sqf *SSubQueryField) Expression() string + func (sqf *SSubQueryField) Label(label string) IQueryField + func (sqf *SSubQueryField) Name() string + func (sqf *SSubQueryField) Reference() string + func (sqf *SSubQueryField) Variables() []interface{} + type STable struct + func NewTableInstance(ts ITableSpec) *STable + func (tbl *STable) Alias() string + func (tbl *STable) Expression() string + func (tbl *STable) Field(name string, alias ...string) IQueryField + func (tbl *STable) Fields() []IQueryField + func (tbl *STable) Query(f ...IQueryField) *SQuery + func (tbl *STable) Variables() []interface{} + type STableField struct + func (c *STableField) Expression() string + func (c *STableField) Label(label string) IQueryField + func (c *STableField) Name() string + func (c *STableField) Reference() string + func (c *STableField) Variables() []interface{} + type STableSpec struct + func NewTableSpecFromStruct(s interface{}, name string) *STableSpec + func (t *STableSpec) DebugInsert(dt interface{}) error + func (t *STableSpec) DebugInsertOrUpdate(dt interface{}) error + func (t *STableSpec) DebugUpdateFields(dt interface{}, fields map[string]interface{}) error + func (t *STableSpec) Decrement(diff interface{}, target interface{}) error + func (t *STableSpec) Increment(diff interface{}, target interface{}) error + func (t *STableSpec) Insert(dt interface{}) error + func (t *STableSpec) InsertOrUpdate(dt interface{}) error + func (ts *STableSpec) AddIndex(unique bool, cols ...string) bool + func (ts *STableSpec) CheckSync() error + func (ts *STableSpec) Clone(name string, autoIncOffset int64) *STableSpec + func (ts *STableSpec) ColumnSpec(name string) IColumnSpec + func (ts *STableSpec) Columns() []IColumnSpec + func (ts *STableSpec) CreateSQL() string + func (ts *STableSpec) DataType() reflect.Type + func (ts *STableSpec) DropForeignKeySQL() []string + func (ts *STableSpec) Exists() bool + func (ts *STableSpec) Expression() string + func (ts *STableSpec) Fetch(dt interface{}) error + func (ts *STableSpec) FetchAll(dest interface{}) error + func (ts *STableSpec) Instance() *STable + func (ts *STableSpec) Name() string + func (ts *STableSpec) PrimaryColumns() []IColumnSpec + func (ts *STableSpec) Query(f ...IQueryField) *SQuery + func (ts *STableSpec) Sync() error + func (ts *STableSpec) SyncSQL() []string + func (ts *STableSpec) Update(dt interface{}, doUpdate func() error) (UpdateDiffs, error) + func (ts *STableSpec) UpdateFields(dt interface{}, fields map[string]interface{}) error + type STextColumn struct + Charset string + func NewTextColumn(name string, tagmap map[string]string, isPointer bool) STextColumn + func (c *STextColumn) ColType() string + func (c *STextColumn) DefinitionString() string + func (c *STextColumn) IsAscii() bool + func (c *STextColumn) IsSearchable() bool + func (c *STextColumn) IsSupportDefault() bool + func (c *STextColumn) IsText() bool + func (c *STextColumn) IsZero(val interface{}) bool + type STimeTypeColumn struct + func NewTimeTypeColumn(name string, typeStr string, tagmap map[string]string, isPointer bool) STimeTypeColumn + func (c *STimeTypeColumn) DefinitionString() string + func (c *STimeTypeColumn) IsText() bool + func (c *STimeTypeColumn) IsZero(val interface{}) bool + type STripleCondition struct + func NewTripleCondition(l IQueryField, r interface{}, r2 interface{}) STripleCondition + func (t *STripleCondition) Variables() []interface{} + type STristateColumn struct + func NewTristateColumn(name string, tagmap map[string]string, isPointer bool) STristateColumn + func (c *STristateColumn) ConvertFromString(str string) string + func (c *STristateColumn) ConvertFromValue(val interface{}) interface{} + func (c *STristateColumn) DefinitionString() string + func (c *STristateColumn) IsZero(val interface{}) bool + type STrueCondition struct + func (t *STrueCondition) Variables() []interface{} + func (t *STrueCondition) WhereClause() string + type STupleCondition struct + func NewTupleCondition(l IQueryField, r interface{}) STupleCondition + func (t *STupleCondition) Variables() []interface{} + type SUnion struct + func Union(query ...IQuery) *SUnion + func UnionWithError(query ...IQuery) (*SUnion, error) + func (uq *SUnion) Alias() string + func (uq *SUnion) Expression() string + func (uq *SUnion) Field(name string, alias ...string) IQueryField + func (uq *SUnion) Fields() []IQueryField + func (uq *SUnion) Limit(limit int) *SUnion + func (uq *SUnion) Offset(offset int) *SUnion + func (uq *SUnion) Query(f ...IQueryField) *SQuery + func (uq *SUnion) Variables() []interface{} + type SUnionQueryField struct + func (sqf *SUnionQueryField) Expression() string + func (sqf *SUnionQueryField) Label(label string) IQueryField + func (sqf *SUnionQueryField) Name() string + func (sqf *SUnionQueryField) Reference() string + func (sqf *SUnionQueryField) Variables() []interface{} + type SUpdateDiff struct + func (ud *SUpdateDiff) String() string + type SUpdateSession struct + type UpdateDiffs map[string]SUpdateDiff + func (uds UpdateDiffs) String() string