Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteTimeRange(db *gorm.DB, table string, start, end *time.Time) *gorm.DB
- func Open(dsn string) gorm.Dialector
- type BindMode
- type Dialect
- func (dialect Dialect) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})
- func (dialect Dialect) ClauseBuilders() map[string]clause.ClauseBuilder
- func (dialector *Dialect) Create(db *gorm.DB)
- func (dialect Dialect) DataTypeOf(field *schema.Field) string
- func (dialect Dialect) DefaultValueOf(field *schema.Field) clause.Expression
- func (dialect Dialect) Delete(db *gorm.DB)
- func (dialect Dialect) Explain(sql string, vars ...interface{}) string
- func (dialect Dialect) Initialize(db *gorm.DB) (err error)
- func (dialect Dialect) Migrator(db *gorm.DB) gorm.Migrator
- func (dialect Dialect) Name() string
- func (dialect Dialect) QuoteTo(writer clause.Writer, str string)
- func (dialect Dialect) RollbackTo(tx *gorm.DB, name string) error
- func (dialect Dialect) SavePoint(tx *gorm.DB, name string) error
- func (dialect Dialect) Update(db *gorm.DB)
- type Migrator
- func (m Migrator) AddColumn(value interface{}, name string) error
- func (m Migrator) AddStableColumn(stable string, column *createclause.Column) error
- func (m Migrator) AddStableTag(stable string, tag *createclause.Column) error
- func (m Migrator) AlterColumn(value interface{}, name string) error
- func (m Migrator) AutoMigrate(values ...interface{}) error
- func (m Migrator) ColumnTypes(value interface{}) (result []gorm.ColumnType, err error)
- func (m Migrator) CreateConstraint(interface{}, string) error
- func (m Migrator) CreateIndex(value interface{}, name string) error
- func (m Migrator) CreateTable(values ...interface{}) error
- func (m Migrator) DropColumn(value interface{}, name string) error
- func (m Migrator) DropConstraint(interface{}, string) error
- func (m Migrator) DropIndex(value interface{}, name string) error
- func (m Migrator) DropStableColumn(stable, column string) error
- func (m Migrator) DropStableTag(stable, tag string) error
- func (m Migrator) DropTable(values ...interface{}) error
- func (m Migrator) FullDataTypeOf(field *schema.Field) clause.Expr
- func (m Migrator) GetIndexes(value interface{}) (indexes []gorm.Index, err error)
- func (m Migrator) GetTables() ([]string, error)
- func (m Migrator) HasColumn(value interface{}, name string) bool
- func (m Migrator) HasConstraint(interface{}, string) bool
- func (m Migrator) HasIndex(value interface{}, name string) bool
- func (m Migrator) HasTable(value interface{}) bool
- func (m Migrator) MigrateColumn(interface{}, *schema.Field, gorm.ColumnType) error
- func (m Migrator) MigrateColumnUnique(interface{}, *schema.Field, gorm.ColumnType) error
- func (m Migrator) ModifyStableColumn(stable string, column *createclause.Column) error
- func (m Migrator) ModifyStableTag(stable string, tag *createclause.Column) error
- func (m Migrator) RenameColumn(interface{}, string, string) error
- func (m Migrator) RenameIndex(interface{}, string, string) error
- func (m Migrator) RenameStableTag(stable, oldName, newName string) error
- func (m Migrator) RenameTable(interface{}, interface{}) error
- func (m Migrator) SetTableTag(table, tag string, value interface{}) error
- func (m Migrator) SetTableTags(table string, tags map[string]interface{}) error
- func (m Migrator) SetTableTagsBatch(updates ...TableTagUpdate) error
- func (m Migrator) TableType(value interface{}) (result gorm.TableType, err error)
- type TableTagUpdate
Constants ¶
const DriverName = "taosWS"
DriverName is the default driver name for TDengine.
Variables ¶
var ( // ErrUpdateNotSupported explains TDengine's insert-based update semantics. ErrUpdateNotSupported = errors.New("tdengine: GORM UPDATE is not supported; insert the same timestamp again to update a row") // ErrDeleteNotSupported directs callers to the time-range API. ErrDeleteNotSupported = errors.New("tdengine: GORM DELETE is not supported; use DeleteTimeRange") // ErrDeleteRangeRequired prevents an unbounded, irreversible deletion. ErrDeleteRangeRequired = errors.New("tdengine: at least one delete time bound is required") )
var ( ErrTagIndexOnly = errors.New("tdengine: indexes are supported only on supertable tags") ErrSingleTagIndexOnly = errors.New("tdengine: a tag index must contain exactly one tag") )
var ( ErrTimestampFirst = errors.New("tdengine: the first data column must be TIMESTAMP") ErrNoDataColumns = errors.New("tdengine: a table requires at least one data column") ErrConstraintsUnsupported = errors.New("tdengine: GORM constraints are not supported") ErrRenameTableUnsupported = errors.New("tdengine: renaming tables through GORM is not supported") ErrCompositeKeyInvalid = errors.New("tdengine: COMPOSITE KEY requires exactly one non-tag integer or VARCHAR column after the timestamp") ErrCompositeKeyMigrationUnsupported = errors.New("tdengine: COMPOSITE KEY can only be declared when creating a table") ErrVirtualTableUnsupported = errors.New("tdengine: GORM migration operations on virtual tables are not supported") )
var ( ErrTagUpdateRequired = errors.New("tdengine: at least one table tag update is required") ErrTagValueRequired = errors.New("tdengine: at least one tag value is required") ErrDuplicateTagUpdateTable = errors.New("tdengine: a table may appear only once in a batch tag update") )
var ErrOnConflictUnsupported = errors.New("tdengine: ON CONFLICT is not supported; insert the same primary key to replace a row")
Functions ¶
func DeleteTimeRange ¶ added in v0.3.0
DeleteTimeRange deletes rows using TDengine's _rowts pseudocolumn. Start is inclusive and end is exclusive. A nil bound leaves that side open; at least one bound is required.
Types ¶
type BindMode ¶ added in v0.3.0
type BindMode uint8
BindMode controls how values are passed to driver-go.
const ( // BindModeAuto follows GORM PrepareStmt and the interpolateParams DSN option. BindModeAuto BindMode = iota // BindModeInterpolate encodes string values as TDengine SQL literals. BindModeInterpolate // BindModePrepared preserves Go values for driver-go prepared statements. BindModePrepared )
type Dialect ¶
func (Dialect) ClauseBuilders ¶
func (dialect Dialect) ClauseBuilders() map[string]clause.ClauseBuilder
func (Dialect) DefaultValueOf ¶
func (dialect Dialect) DefaultValueOf(field *schema.Field) clause.Expression
type Migrator ¶
Migrator implements the subset of GORM migration operations that maps to TDengine tables and supertables. AutoMigrate is intentionally additive: it creates missing objects and adds missing columns/tags, but never drops or changes existing definitions.
func (Migrator) AddStableColumn ¶ added in v0.3.0
func (m Migrator) AddStableColumn(stable string, column *createclause.Column) error
func (Migrator) AddStableTag ¶ added in v0.3.0
func (m Migrator) AddStableTag(stable string, tag *createclause.Column) error
func (Migrator) AlterColumn ¶
func (Migrator) AutoMigrate ¶
func (Migrator) ColumnTypes ¶ added in v0.3.0
func (m Migrator) ColumnTypes(value interface{}) (result []gorm.ColumnType, err error)
ColumnTypes reads TDengine's native metadata instead of the MySQL-style information_schema tables used by GORM's default migrator.
func (Migrator) CreateConstraint ¶ added in v0.3.0
func (Migrator) CreateIndex ¶ added in v0.3.0
func (Migrator) CreateTable ¶ added in v0.3.0
func (Migrator) DropColumn ¶ added in v0.3.0
func (Migrator) DropConstraint ¶
func (Migrator) DropStableColumn ¶ added in v0.3.0
func (Migrator) DropStableTag ¶ added in v0.3.0
func (Migrator) GetIndexes ¶ added in v0.3.0
func (Migrator) HasConstraint ¶ added in v0.3.0
func (Migrator) MigrateColumn ¶ added in v0.3.0
MigrateColumn is a no-op because automatic type changes can be destructive in TDengine. Call AlterColumn explicitly after reviewing the change.
func (Migrator) MigrateColumnUnique ¶ added in v0.3.0
func (Migrator) ModifyStableColumn ¶ added in v0.3.0
func (m Migrator) ModifyStableColumn(stable string, column *createclause.Column) error
func (Migrator) ModifyStableTag ¶ added in v0.3.0
func (m Migrator) ModifyStableTag(stable string, tag *createclause.Column) error
func (Migrator) RenameStableTag ¶ added in v0.3.0
func (Migrator) RenameTable ¶ added in v0.3.0
func (Migrator) SetTableTag ¶ added in v0.3.0
func (Migrator) SetTableTags ¶ added in v0.3.0
func (Migrator) SetTableTagsBatch ¶ added in v0.3.0
func (m Migrator) SetTableTagsBatch(updates ...TableTagUpdate) error