dialector

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package dialector implements a dual-model GORM dialector for Apache IoTDB.

Index

Constants

View Source
const (
	// TreeModel targets IoTDB 1.3.1 hierarchical paths and is the default.
	TreeModel = backend.TreeModel
	// TableModel targets IoTDB 2.x relational tables; 2.0.8 is integration-verified.
	TableModel = backend.TableModel
)
View Source
const (
	// Milliseconds is the default IoTDB timestamp precision.
	Milliseconds = iotdbsql.Milliseconds
	// Microseconds selects microsecond timestamp conversion.
	Microseconds = iotdbsql.Microseconds
	// Nanoseconds selects nanosecond timestamp conversion.
	Nanoseconds = iotdbsql.Nanoseconds
)

Variables

View Source
var ErrUnsupportedOperation = errors.New("iotdb: unsupported GORM operation")

ErrUnsupportedOperation marks GORM semantics that IoTDB cannot safely emulate.

Functions

func Bool

func Bool(value bool) *bool

Bool returns a pointer useful for explicit boolean configuration values.

func New

func New(config Config) gorm.Dialector

New creates a dialector from structured configuration.

func Open

func Open(dsn string) gorm.Dialector

Open creates a TreeModel-by-default dialector from an iotdb:// DSN.

Types

type Config

type Config struct {
	DSN                    string
	ModelMode              ModelMode
	NodeURLs               []string
	Username               string
	Password               string
	Database               string
	Aligned                *bool
	PoolSize               int
	ConnectTimeout         time.Duration
	AcquireTimeout         time.Duration
	QueryTimeout           time.Duration
	FetchSize              int32
	TimeZone               string
	ConnectRetryMax        int
	EnableRPCCompression   bool
	BatchSize              int
	MaxBatchBytes          int
	TableInsertConcurrency int
	TimePrecision          TimePrecision
	DevicePathField        string
	DevicePathFunc         DevicePathFunc
	AllowSQLFallback       bool
	Conn                   gorm.ConnPool
}

Config configures the IoTDB GORM dialector and its one official client pool.

type DevicePathFunc

type DevicePathFunc func(logicalTable string, row any) (string, error)

DevicePathFunc resolves an optional per-row TreeModel device path.

type Dialector

type Dialector struct {
	// contains filtered or unexported fields
}

Dialector implements gorm.Dialector and owns one official-client backend.

func (*Dialector) BindVarTo

func (d *Dialector) BindVarTo(writer clause.Writer, _ *gorm.Statement, _ interface{})

BindVarTo writes one positional placeholder for the database/sql binder.

func (*Dialector) Close

func (d *Dialector) Close() error

Close closes database/sql wrappers and then the owned official pool.

func (*Dialector) DataTypeOf

func (d *Dialector) DataTypeOf(field *schema.Field) string

DataTypeOf returns the IoTDB type corresponding to one GORM field.

func (*Dialector) DefaultValueOf

func (d *Dialector) DefaultValueOf(field *schema.Field) clause.Expression

DefaultValueOf reports the configured default expression for DryRun SQL only.

func (*Dialector) Explain

func (d *Dialector) Explain(query string, vars ...interface{}) string

Explain renders SQL for GORM logs and DryRun output.

func (*Dialector) Initialize

func (d *Dialector) Initialize(db *gorm.DB) error

Initialize builds one official pool and registers explicit GORM behavior.

func (*Dialector) Migrator

func (d *Dialector) Migrator(db *gorm.DB) gorm.Migrator

Migrator returns a non-destructive model-specific migrator.

func (*Dialector) Name

func (d *Dialector) Name() string

Name returns the GORM dialector name.

func (*Dialector) Ping

func (d *Dialector) Ping(ctx context.Context) error

Ping performs a real backend round trip.

func (*Dialector) QuoteTo

func (d *Dialector) QuoteTo(writer clause.Writer, identifier string)

QuoteTo writes validated IoTDB identifiers without treating a Tree path as one name.

func (*Dialector) RollbackTo

func (d *Dialector) RollbackTo(*gorm.DB, string) error

RollbackTo rejects savepoint emulation.

func (*Dialector) SavePoint

func (d *Dialector) SavePoint(*gorm.DB, string) error

SavePoint rejects savepoint emulation.

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator implements only idempotent, non-destructive IoTDB migrations.

func (Migrator) AddColumn

func (m Migrator) AddColumn(dst interface{}, fieldName string) error

AddColumn adds only the requested missing Tree measurement or table column.

func (Migrator) AlterColumn

func (m Migrator) AlterColumn(interface{}, string) error

AlterColumn rejects in-place type changes.

func (Migrator) AutoMigrate

func (m Migrator) AutoMigrate(dst ...interface{}) error

AutoMigrate creates a missing device/table and adds only compatible columns.

func (Migrator) ColumnTypes

func (m Migrator) ColumnTypes(dst interface{}) ([]gorm.ColumnType, error)

ColumnTypes returns TreeModel or TableModel type metadata.

func (Migrator) CreateConstraint

func (m Migrator) CreateConstraint(interface{}, string) error

CreateConstraint rejects relational constraints.

func (Migrator) CreateIndex

func (m Migrator) CreateIndex(interface{}, string) error

CreateIndex rejects relational indexes.

func (Migrator) CreateTable

func (m Migrator) CreateTable(dst ...interface{}) error

CreateTable creates TreeModel measurements or one TableModel table.

func (Migrator) CreateView

func (m Migrator) CreateView(string, gorm.ViewOption) error

CreateView rejects unsupported views.

func (Migrator) CurrentDatabase

func (m Migrator) CurrentDatabase() string

CurrentDatabase returns the configured logical database.

func (Migrator) DropColumn

func (m Migrator) DropColumn(interface{}, string) error

DropColumn rejects destructive column removal.

func (Migrator) DropConstraint

func (m Migrator) DropConstraint(interface{}, string) error

DropConstraint rejects relational constraints.

func (Migrator) DropIndex

func (m Migrator) DropIndex(interface{}, string) error

DropIndex rejects relational indexes.

func (Migrator) DropTable

func (m Migrator) DropTable(...interface{}) error

DropTable rejects destructive schema removal.

func (Migrator) DropView

func (m Migrator) DropView(string) error

DropView rejects unsupported views.

func (Migrator) FullDataTypeOf

func (m Migrator) FullDataTypeOf(field *schema.Field) clause.Expr

FullDataTypeOf returns one IoTDB type expression.

func (Migrator) GetTables

func (m Migrator) GetTables() ([]string, error)

GetTables lists devices below the TreeModel root or tables in the TableModel database.

func (Migrator) GetTypeAliases

func (m Migrator) GetTypeAliases(databaseTypeName string) []string

GetTypeAliases returns the narrow set of accepted server aliases.

func (Migrator) HasColumn

func (m Migrator) HasColumn(dst interface{}, fieldName string) bool

HasColumn reports whether a measurement or table column exists.

func (Migrator) HasConstraint

func (m Migrator) HasConstraint(interface{}, string) bool

HasConstraint always reports false because constraints are unsupported.

func (Migrator) HasIndex

func (m Migrator) HasIndex(interface{}, string) bool

HasIndex always reports false because relational indexes are unsupported.

func (Migrator) HasTable

func (m Migrator) HasTable(dst interface{}) bool

HasTable reports whether a TreeModel device or TableModel table exists.

func (Migrator) MigrateColumn

func (m Migrator) MigrateColumn(dst interface{}, field *schema.Field, columnType gorm.ColumnType) error

MigrateColumn accepts matching types and rejects incompatible changes.

func (Migrator) RenameColumn

func (m Migrator) RenameColumn(interface{}, string, string) error

RenameColumn rejects measurement and table-column renames.

func (Migrator) RenameIndex

func (m Migrator) RenameIndex(interface{}, string, string) error

RenameIndex rejects relational index renames.

func (Migrator) RenameTable

func (m Migrator) RenameTable(interface{}, interface{}) error

RenameTable rejects path and table renames.

type ModelMode

type ModelMode = backend.ModelMode

ModelMode selects the IoTDB data model.

type TimePrecision

type TimePrecision = iotdbsql.TimePrecision

TimePrecision controls time.Time conversion for SQL predicates and Tablets.

Jump to

Keyboard shortcuts

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