Documentation
¶
Overview ¶
Package duckdb provides a GORM driver for DuckDB database. This file contains minimal array support for basic DuckDB array operations.
Index ¶
- Constants
- Variables
- func InitializeExtensions(db *gorm.DB) error
- func IsColumnNotFoundError(err error) bool
- func IsDuplicateKeyError(err error) bool
- func IsForeignKeyError(err error) bool
- func IsNotNullError(err error) bool
- func IsSpecificError(err error, target error) bool
- func IsTableNotFoundError(err error) bool
- func New(config Config) gorm.Dialector
- func NewWithExtensions(config Config, extensionConfig *ExtensionConfig) gorm.Dialector
- func Open(dsn string) gorm.Dialector
- func OpenWithExtensions(dsn string, extensionConfig *ExtensionConfig) gorm.Dialector
- type AnalyticalFunctionType
- type ArrayLiteral
- type BLOBType
- type BitStringType
- func (b BitStringType) Count() int
- func (b BitStringType) Get(position int) (bool, error)
- func (b BitStringType) GormDataType() string
- func (b *BitStringType) Scan(value interface{}) error
- func (b *BitStringType) Set(position int, value bool) error
- func (b BitStringType) ToBinaryString() string
- func (b BitStringType) ToHexString() string
- func (b BitStringType) Value() (driver.Value, error)
- type Config
- type ConstraintType
- type DecimalType
- type Dialector
- func (dialector Dialector) BindVarTo(writer clause.Writer, _ *gorm.Statement, _ interface{})
- func (dialector Dialector) DataTypeOf(field *schema.Field) string
- func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression
- func (dialector Dialector) Explain(sql string, vars ...interface{}) string
- func (dialector Dialector) Initialize(db *gorm.DB) error
- func (dialector Dialector) Migrator(db *gorm.DB) gorm.Migrator
- func (dialector Dialector) Name() string
- func (dialector Dialector) QuoteTo(writer clause.Writer, str string)
- func (dialector Dialector) RollbackTo(tx *gorm.DB, name string) error
- func (dialector Dialector) SavePoint(tx *gorm.DB, name string) error
- func (dialector Dialector) Translate(err error) error
- type DuckDBIndex
- type ENUMType
- type ErrorTranslator
- type Extension
- type ExtensionConfig
- type ExtensionHelper
- func (h *ExtensionHelper) EnableAnalytics() error
- func (h *ExtensionHelper) EnableCloudAccess() error
- func (h *ExtensionHelper) EnableDataFormats() error
- func (h *ExtensionHelper) EnableMachineLearning() error
- func (h *ExtensionHelper) EnableSpatial() error
- func (h *ExtensionHelper) EnableTimeSeries() error
- type ExtensionManager
- func (m *ExtensionManager) GetExtension(name string) (*Extension, error)
- func (m *ExtensionManager) GetLoadedExtensions() ([]Extension, error)
- func (m *ExtensionManager) InstallExtension(name string) error
- func (m *ExtensionManager) IsExtensionLoaded(name string) bool
- func (m *ExtensionManager) ListExtensions() ([]Extension, error)
- func (m *ExtensionManager) LoadExtension(name string) error
- func (m *ExtensionManager) LoadExtensions(names []string) error
- func (m *ExtensionManager) PreloadExtensions() error
- type FloatArray
- type GEOMETRYType
- func (g GEOMETRYType) GetBounds() map[string]float64
- func (GEOMETRYType) GormDataType() string
- func (g GEOMETRYType) IsEmpty() bool
- func (g GEOMETRYType) IsPoint() bool
- func (g GEOMETRYType) IsPolygon() bool
- func (g *GEOMETRYType) Scan(value interface{}) error
- func (g *GEOMETRYType) SetProperty(key string, value interface{})
- func (g GEOMETRYType) Value() (driver.Value, error)
- type HugeIntType
- type IntArray
- type IntervalType
- type JSONType
- type ListType
- type MapType
- type Migrator
- func (m Migrator) AlterColumn(value interface{}, field string) error
- func (m Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{})
- func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error)
- func (m Migrator) CreateTable(values ...interface{}) error
- func (m Migrator) CreateView(name string, option gorm.ViewOption) error
- func (m Migrator) CurrentDatabase() (name string)
- func (m Migrator) DropConstraint(value interface{}, name string) error
- func (m Migrator) DropIndex(value interface{}, name string) error
- func (m Migrator) DropView(name string) error
- func (m Migrator) FullDataTypeOf(field *schema.Field) clause.Expr
- func (m Migrator) GetIndexes(value interface{}) ([]gorm.Index, error)
- func (m Migrator) GetTables() (tableList []string, err error)
- func (m Migrator) GetTypeAliases(databaseTypeName string) []string
- func (m Migrator) HasColumn(value interface{}, field string) bool
- func (m Migrator) HasConstraint(value interface{}, name string) bool
- func (m Migrator) HasIndex(value interface{}, name string) bool
- func (m Migrator) HasTable(value interface{}) bool
- func (m Migrator) RenameColumn(value interface{}, oldName, newName string) error
- func (m Migrator) RenameIndex(value interface{}, oldName, newName string) error
- func (m Migrator) TableType(value interface{}) (gorm.TableType, error)
- type NestedArrayType
- func (n NestedArrayType) Get(index int) (interface{}, error)
- func (n NestedArrayType) GormDataType() string
- func (n NestedArrayType) Length() int
- func (n *NestedArrayType) Scan(value interface{}) error
- func (n NestedArrayType) Slice(start, end int) (NestedArrayType, error)
- func (n NestedArrayType) Value() (driver.Value, error)
- type PerformanceMetricsType
- func (p *PerformanceMetricsType) AddMetric(key string, value interface{})
- func (p PerformanceMetricsType) GetMetric(key string) (interface{}, bool)
- func (PerformanceMetricsType) GormDataType() string
- func (p *PerformanceMetricsType) Scan(value interface{}) error
- func (p PerformanceMetricsType) Summary() string
- func (p PerformanceMetricsType) Value() (driver.Value, error)
- type QueryHintType
- type SimpleArrayScanner
- type StringArray
- type StructType
- type TimestampTZType
- type UNIONType
- type UUIDType
Constants ¶
const ( // Core Extensions (built-in) ExtensionJSON = "json" ExtensionParquet = "parquet" ExtensionICU = "icu" // Analytics Extensions ExtensionAutoComplete = "autocomplete" ExtensionFTS = "fts" ExtensionTPCH = "tpch" ExtensionTPCDS = "tpcds" // Data Format Extensions ExtensionCSV = "csv" ExtensionExcel = "excel" ExtensionArrow = "arrow" ExtensionSQLite = "sqlite" // Networking Extensions ExtensionHTTPS = "httpfs" ExtensionS3 = "aws" ExtensionAzure = "azure" // Geospatial Extensions ExtensionSpatial = "spatial" // Machine Learning Extensions ExtensionML = "ml" // Time Series Extensions ExtensionTimeSeries = "timeseries" // Visualization Extensions ExtensionVisualization = "visualization" )
Common DuckDB extensions
Variables ¶
var ( ErrUniqueConstraint = errors.New("UNIQUE constraint failed") ErrForeignKey = errors.New("FOREIGN KEY constraint failed") ErrCheckConstraint = errors.New("CHECK constraint failed") ErrNotNullConstraint = errors.New("NOT NULL constraint failed") ErrNoSuchTable = errors.New("no such table") ErrNoSuchColumn = errors.New("no such column") ErrSyntaxError = errors.New("syntax error") ErrDatabaseLocked = errors.New("database is locked") )
Common DuckDB error patterns
Functions ¶
func InitializeExtensions ¶ added in v0.4.0
InitializeExtensions manually triggers preloading of configured extensions This should be called after the database connection is fully established
func IsColumnNotFoundError ¶ added in v0.4.0
IsColumnNotFoundError checks if the error is a column not found error
func IsDuplicateKeyError ¶ added in v0.4.0
IsDuplicateKeyError checks if the error is a duplicate key constraint violation
func IsForeignKeyError ¶ added in v0.4.0
IsForeignKeyError checks if the error is a foreign key constraint violation
func IsNotNullError ¶ added in v0.4.0
IsNotNullError checks if the error is a not null constraint violation
func IsSpecificError ¶ added in v0.4.0
IsSpecificError checks if an error matches a specific DuckDB error type
func IsTableNotFoundError ¶ added in v0.4.0
IsTableNotFoundError checks if the error is a table not found error
func NewWithExtensions ¶
func NewWithExtensions(config Config, extensionConfig *ExtensionConfig) gorm.Dialector
NewWithExtensions creates a new dialector with extension support
func OpenWithExtensions ¶
func OpenWithExtensions(dsn string, extensionConfig *ExtensionConfig) gorm.Dialector
OpenWithExtensions creates a dialector with extension support using DSN
Types ¶
type AnalyticalFunctionType ¶ added in v0.5.2
type AnalyticalFunctionType struct { FunctionName string `json:"function_name"` // MEDIAN, MODE, PERCENTILE, etc. Column string `json:"column"` // Target column Parameters map[string]interface{} `json:"parameters"` // Function parameters WindowFrame string `json:"window_frame"` // OVER clause details }
AnalyticalFunctionType represents advanced DuckDB analytical functions
func NewAnalyticalFunction ¶ added in v0.5.2
func NewAnalyticalFunction(functionName, column string, parameters map[string]interface{}, windowFrame string) AnalyticalFunctionType
NewAnalyticalFunction creates a new AnalyticalFunctionType
func (AnalyticalFunctionType) GormDataType ¶ added in v0.5.2
func (AnalyticalFunctionType) GormDataType() string
GormDataType implements the GormDataTypeInterface for AnalyticalFunctionType
func (*AnalyticalFunctionType) Scan ¶ added in v0.5.2
func (a *AnalyticalFunctionType) Scan(value interface{}) error
Scan implements sql.Scanner interface for AnalyticalFunctionType
func (AnalyticalFunctionType) ToSQL ¶ added in v0.5.2
func (a AnalyticalFunctionType) ToSQL() string
ToSQL generates the SQL function syntax
type ArrayLiteral ¶
type ArrayLiteral struct {
Data interface{}
}
ArrayLiteral wraps a Go slice to be formatted as a DuckDB array literal
type BLOBType ¶ added in v0.5.2
type BLOBType struct { Data []byte `json:"data"` // Binary data content MimeType string `json:"mimeType"` // MIME type for content identification Size int64 `json:"size"` // Size in bytes }
BLOBType represents a DuckDB BLOB (Binary Large Object) type Essential core type for binary data storage and manipulation
func (BLOBType) GetContentType ¶ added in v0.5.2
GetContentType returns the MIME type or detects it from data
func (BLOBType) GormDataType ¶ added in v0.5.2
GormDataType implements the GormDataTypeInterface for BLOBType
type BitStringType ¶ added in v0.5.2
type BitStringType struct { Bits []bool `json:"bits"` // Individual bit values Length int `json:"length"` // Fixed length (0 = variable length) }
BitStringType represents a DuckDB BIT/BITSTRING type
func NewBitString ¶ added in v0.5.2
func NewBitString(bits []bool, length int) BitStringType
NewBitString creates a new BitStringType
func NewBitStringFromString ¶ added in v0.5.2
func NewBitStringFromString(bitStr string, length int) (BitStringType, error)
NewBitStringFromString creates a BitStringType from a binary string
func (BitStringType) Count ¶ added in v0.5.2
func (b BitStringType) Count() int
Count returns the number of set bits (1s)
func (BitStringType) Get ¶ added in v0.5.2
func (b BitStringType) Get(position int) (bool, error)
Get returns the bit value at the specified position
func (BitStringType) GormDataType ¶ added in v0.5.2
func (b BitStringType) GormDataType() string
GormDataType implements the GormDataTypeInterface for BitStringType
func (*BitStringType) Scan ¶ added in v0.5.2
func (b *BitStringType) Scan(value interface{}) error
Scan implements sql.Scanner interface for BitStringType
func (*BitStringType) Set ¶ added in v0.5.2
func (b *BitStringType) Set(position int, value bool) error
Set sets the bit value at the specified position
func (BitStringType) ToBinaryString ¶ added in v0.5.2
func (b BitStringType) ToBinaryString() string
ToBinaryString returns the bit string as binary representation
func (BitStringType) ToHexString ¶ added in v0.5.2
func (b BitStringType) ToHexString() string
ToHexString returns the bit string as hexadecimal representation
type ConstraintType ¶ added in v0.5.2
type ConstraintType struct { ConstraintType string `json:"constraint_type"` // CHECK, UNIQUE, FOREIGN_KEY, etc. Expression string `json:"expression"` // Constraint expression Options map[string]interface{} `json:"options"` // Additional constraint options }
ConstraintType represents advanced DuckDB constraints
func NewConstraint ¶ added in v0.5.2
func NewConstraint(constraintType, expression string, options map[string]interface{}) ConstraintType
NewConstraint creates a new ConstraintType
func (ConstraintType) GormDataType ¶ added in v0.5.2
func (ConstraintType) GormDataType() string
GormDataType implements the GormDataTypeInterface for ConstraintType
func (*ConstraintType) Scan ¶ added in v0.5.2
func (c *ConstraintType) Scan(value interface{}) error
Scan implements sql.Scanner interface for ConstraintType
func (ConstraintType) ToSQL ¶ added in v0.5.2
func (c ConstraintType) ToSQL() string
ToSQL generates the SQL constraint syntax
type DecimalType ¶ added in v0.5.2
type DecimalType struct { Data string // Store as string to preserve precision Precision int // Total digits Scale int // Digits after decimal point }
DecimalType represents a DuckDB DECIMAL type with precise numeric operations
func NewDecimal ¶ added in v0.5.2
func NewDecimal(value string, precision, scale int) DecimalType
NewDecimal creates a new DecimalType from a string representation
func (DecimalType) Float64 ¶ added in v0.5.2
func (d DecimalType) Float64() (float64, error)
Float64 returns the decimal value as a float64 (may lose precision)
func (DecimalType) GormDataType ¶ added in v0.5.2
func (d DecimalType) GormDataType() string
GormDataType implements the GormDataTypeInterface for DecimalType
func (*DecimalType) Scan ¶ added in v0.5.2
func (d *DecimalType) Scan(value interface{}) error
Scan implements sql.Scanner interface for DecimalType
func (DecimalType) String ¶ added in v0.5.2
func (d DecimalType) String() string
String returns the string representation of the decimal
type Dialector ¶
type Dialector struct {
*Config
}
Dialector implements gorm.Dialector interface for DuckDB database.
func (Dialector) DataTypeOf ¶
DataTypeOf returns the SQL data type for a given field.
func (Dialector) DefaultValueOf ¶
func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression
DefaultValueOf returns the default value clause for a field.
func (Dialector) Initialize ¶
Initialize implements gorm.Dialector
func (Dialector) RollbackTo ¶
RollbackTo rolls back to the given savepoint.
type DuckDBIndex ¶ added in v0.5.2
type DuckDBIndex struct { TableName string IndexName string ColumnNames []string IsUnique bool IsPrimary bool Options string }
DuckDBIndex implements gorm.Index interface for DuckDB
func (DuckDBIndex) Columns ¶ added in v0.5.2
func (idx DuckDBIndex) Columns() []string
func (DuckDBIndex) Name ¶ added in v0.5.2
func (idx DuckDBIndex) Name() string
func (DuckDBIndex) Option ¶ added in v0.5.2
func (idx DuckDBIndex) Option() string
func (DuckDBIndex) PrimaryKey ¶ added in v0.5.2
func (idx DuckDBIndex) PrimaryKey() (isPrimaryKey bool, ok bool)
func (DuckDBIndex) Table ¶ added in v0.5.2
func (idx DuckDBIndex) Table() string
func (DuckDBIndex) Unique ¶ added in v0.5.2
func (idx DuckDBIndex) Unique() (unique bool, ok bool)
type ENUMType ¶ added in v0.5.2
type ENUMType struct { Values []string `json:"values"` // Allowed enum values Selected string `json:"selected"` // Current selected value Name string `json:"name"` // Enum type name }
ENUMType represents a DuckDB ENUM type with predefined allowed values
func (ENUMType) GormDataType ¶ added in v0.5.2
GormDataType implements the GormDataTypeInterface for ENUMType
type ErrorTranslator ¶ added in v0.4.0
type ErrorTranslator struct{}
ErrorTranslator implements gorm.ErrorTranslator for DuckDB
func (ErrorTranslator) Translate ¶ added in v0.4.0
func (et ErrorTranslator) Translate(err error) error
Translate converts DuckDB errors to GORM errors
type Extension ¶
type Extension struct { Name string `json:"name"` Description string `json:"description,omitempty"` Loaded bool `json:"loaded"` Installed bool `json:"installed"` BuiltIn bool `json:"built_in,omitempty"` Version string `json:"version,omitempty"` }
Extension represents a DuckDB extension with its metadata and status
type ExtensionConfig ¶
type ExtensionConfig struct { // AutoInstall automatically installs extensions when loading AutoInstall bool // PreloadExtensions list of extensions to load on database connection PreloadExtensions []string // Timeout for extension operations (0 = no timeout) Timeout time.Duration // RepositoryURL custom extension repository URL RepositoryURL string // AllowUnsigned allows loading unsigned extensions (security risk) AllowUnsigned bool }
ExtensionConfig holds configuration for extension management
type ExtensionHelper ¶
type ExtensionHelper struct {
// contains filtered or unexported fields
}
ExtensionHelper provides convenience methods for common extension operations
func NewExtensionHelper ¶
func NewExtensionHelper(manager *ExtensionManager) *ExtensionHelper
NewExtensionHelper creates a new extension helper
func (*ExtensionHelper) EnableAnalytics ¶
func (h *ExtensionHelper) EnableAnalytics() error
EnableAnalytics loads common analytics extensions
func (*ExtensionHelper) EnableCloudAccess ¶
func (h *ExtensionHelper) EnableCloudAccess() error
EnableCloudAccess loads cloud storage extensions
func (*ExtensionHelper) EnableDataFormats ¶
func (h *ExtensionHelper) EnableDataFormats() error
EnableDataFormats loads common data format extensions
func (*ExtensionHelper) EnableMachineLearning ¶
func (h *ExtensionHelper) EnableMachineLearning() error
EnableMachineLearning loads ML extensions
func (*ExtensionHelper) EnableSpatial ¶
func (h *ExtensionHelper) EnableSpatial() error
EnableSpatial loads geospatial extensions
func (*ExtensionHelper) EnableTimeSeries ¶
func (h *ExtensionHelper) EnableTimeSeries() error
EnableTimeSeries loads time series extensions
type ExtensionManager ¶
type ExtensionManager struct {
// contains filtered or unexported fields
}
ExtensionManager handles DuckDB extension operations
func GetExtensionManager ¶
func GetExtensionManager(db *gorm.DB) (*ExtensionManager, error)
GetExtensionManager retrieves the extension manager from a database instance
func MustGetExtensionManager ¶
func MustGetExtensionManager(db *gorm.DB) *ExtensionManager
MustGetExtensionManager retrieves the extension manager, panics if not found
func NewExtensionManager ¶
func NewExtensionManager(db *gorm.DB, config *ExtensionConfig) *ExtensionManager
NewExtensionManager creates a new extension manager instance
func (*ExtensionManager) GetExtension ¶
func (m *ExtensionManager) GetExtension(name string) (*Extension, error)
GetExtension returns information about a specific extension
func (*ExtensionManager) GetLoadedExtensions ¶
func (m *ExtensionManager) GetLoadedExtensions() ([]Extension, error)
GetLoadedExtensions returns all currently loaded extensions
func (*ExtensionManager) InstallExtension ¶
func (m *ExtensionManager) InstallExtension(name string) error
InstallExtension installs an extension from the repository
func (*ExtensionManager) IsExtensionLoaded ¶
func (m *ExtensionManager) IsExtensionLoaded(name string) bool
IsExtensionLoaded checks if an extension is currently loaded
func (*ExtensionManager) ListExtensions ¶
func (m *ExtensionManager) ListExtensions() ([]Extension, error)
ListExtensions returns all available extensions
func (*ExtensionManager) LoadExtension ¶
func (m *ExtensionManager) LoadExtension(name string) error
LoadExtension loads an extension, optionally installing it first
func (*ExtensionManager) LoadExtensions ¶
func (m *ExtensionManager) LoadExtensions(names []string) error
LoadExtensions loads multiple extensions
func (*ExtensionManager) PreloadExtensions ¶
func (m *ExtensionManager) PreloadExtensions() error
PreloadExtensions loads all configured preload extensions
type FloatArray ¶
type FloatArray []float64
FloatArray represents a DuckDB DOUBLE[] array type
func (FloatArray) GormDataType ¶
func (FloatArray) GormDataType() string
GormDataType implements the GormDataTypeInterface for FloatArray
func (*FloatArray) Scan ¶
func (a *FloatArray) Scan(value interface{}) error
Scan implements sql.Scanner interface for FloatArray
type GEOMETRYType ¶ added in v0.5.2
type GEOMETRYType struct { WKT string `json:"wkt"` // Well-Known Text representation SRID int `json:"srid"` // Spatial Reference System Identifier GeomType string `json:"geomType"` // Geometry type (POINT, LINESTRING, POLYGON, etc.) Dimensions int `json:"dimensions"` // 2D, 3D, or 4D Properties map[string]interface{} `json:"properties"` // Additional spatial properties }
GEOMETRYType represents a DuckDB GEOMETRY type for spatial data Critical core type for geospatial analysis and location-based operations
func NewGeometry ¶ added in v0.5.2
func NewGeometry(wkt string, srid int) GEOMETRYType
NewGeometry creates a new GEOMETRYType from Well-Known Text
func (GEOMETRYType) GetBounds ¶ added in v0.5.2
func (g GEOMETRYType) GetBounds() map[string]float64
GetBounds returns the bounding box of the geometry (simplified implementation)
func (GEOMETRYType) GormDataType ¶ added in v0.5.2
func (GEOMETRYType) GormDataType() string
GormDataType implements the GormDataTypeInterface for GEOMETRYType
func (GEOMETRYType) IsEmpty ¶ added in v0.5.2
func (g GEOMETRYType) IsEmpty() bool
IsEmpty returns true if the geometry has no WKT data
func (GEOMETRYType) IsPoint ¶ added in v0.5.2
func (g GEOMETRYType) IsPoint() bool
IsPoint returns true if the geometry is a POINT
func (GEOMETRYType) IsPolygon ¶ added in v0.5.2
func (g GEOMETRYType) IsPolygon() bool
IsPolygon returns true if the geometry is a POLYGON
func (*GEOMETRYType) Scan ¶ added in v0.5.2
func (g *GEOMETRYType) Scan(value interface{}) error
Scan implements sql.Scanner interface for GEOMETRYType
func (*GEOMETRYType) SetProperty ¶ added in v0.5.2
func (g *GEOMETRYType) SetProperty(key string, value interface{})
SetProperty sets a custom property for the geometry
type HugeIntType ¶ added in v0.5.2
HugeIntType represents a DuckDB HUGEINT (128-bit integer)
func NewHugeInt ¶ added in v0.5.2
func NewHugeInt(value interface{}) (HugeIntType, error)
NewHugeInt creates a new HugeIntType from various sources
func (HugeIntType) GormDataType ¶ added in v0.5.2
func (HugeIntType) GormDataType() string
GormDataType implements the GormDataTypeInterface for HugeIntType
func (HugeIntType) Int64 ¶ added in v0.5.2
func (h HugeIntType) Int64() (int64, error)
Int64 returns the value as int64 if it fits, otherwise returns an error
func (*HugeIntType) Scan ¶ added in v0.5.2
func (h *HugeIntType) Scan(value interface{}) error
Scan implements sql.Scanner interface for HugeIntType
func (HugeIntType) String ¶ added in v0.5.2
func (h HugeIntType) String() string
String returns the string representation
type IntArray ¶
type IntArray []int64
IntArray represents a DuckDB INTEGER[] array type
func (IntArray) GormDataType ¶
GormDataType implements the GormDataTypeInterface for IntArray
type IntervalType ¶ added in v0.5.2
type IntervalType struct { Years int Months int Days int Hours int Minutes int Seconds int Micros int }
IntervalType represents a DuckDB INTERVAL type for time calculations
func NewInterval ¶ added in v0.5.2
func NewInterval(years, months, days, hours, minutes, seconds, micros int) IntervalType
NewInterval creates a new IntervalType
func (IntervalType) GormDataType ¶ added in v0.5.2
func (IntervalType) GormDataType() string
GormDataType implements the GormDataTypeInterface for IntervalType
func (*IntervalType) Scan ¶ added in v0.5.2
func (i *IntervalType) Scan(value interface{}) error
Scan implements sql.Scanner interface for IntervalType
func (IntervalType) ToDuration ¶ added in v0.5.2
func (i IntervalType) ToDuration() time.Duration
ToDuration converts the interval to a Go time.Duration (approximate for days/months/years)
type JSONType ¶ added in v0.5.2
type JSONType struct {
Data interface{} // Can hold any JSON-serializable data
}
JSONType represents a DuckDB JSON type with native JSON operations
func NewJSON ¶ added in v0.5.2
func NewJSON(data interface{}) JSONType
NewJSON creates a new JSONType from any JSON-serializable data
func (JSONType) GormDataType ¶ added in v0.5.2
GormDataType implements the GormDataTypeInterface for JSONType
type ListType ¶ added in v0.5.2
type ListType []interface{}
ListType represents a DuckDB LIST type - dynamic arrays with variable element types
func (ListType) GormDataType ¶ added in v0.5.2
GormDataType implements the GormDataTypeInterface for ListType
type MapType ¶ added in v0.5.2
type MapType map[string]interface{}
MapType represents a DuckDB MAP type - key-value pairs with typed keys and values
func (MapType) GormDataType ¶ added in v0.5.2
GormDataType implements the GormDataTypeInterface for MapType
type Migrator ¶
Migrator implements gorm.Migrator interface for DuckDB database.
func (Migrator) AlterColumn ¶
AlterColumn modifies a column definition in DuckDB, handling syntax limitations.
func (Migrator) BuildIndexOptions ¶ added in v0.5.2
func (m Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{})
BuildIndexOptions builds index options for DuckDB
func (Migrator) ColumnTypes ¶ added in v0.5.2
func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error)
ColumnTypes returns comprehensive column type information for the given value
func (Migrator) CreateTable ¶ added in v0.4.0
CreateTable overrides the default CreateTable to handle DuckDB-specific auto-increment sequences
func (Migrator) CreateView ¶
func (m Migrator) CreateView(name string, option gorm.ViewOption) error
CreateView creates a database view.
func (Migrator) CurrentDatabase ¶
CurrentDatabase returns the current database name.
func (Migrator) DropConstraint ¶
DropConstraint drops a constraint from the database.
func (Migrator) FullDataTypeOf ¶
FullDataTypeOf returns the full data type for a field including constraints. Override FullDataTypeOf to prevent GORM from adding duplicate PRIMARY KEY clauses
func (Migrator) GetIndexes ¶ added in v0.5.2
GetIndexes returns comprehensive index information for the given value
func (Migrator) GetTypeAliases ¶
GetTypeAliases returns type aliases for the given database type name.
func (Migrator) HasConstraint ¶
HasConstraint checks if a constraint exists in the database.
func (Migrator) RenameColumn ¶
RenameColumn renames a column in the database table.
func (Migrator) RenameIndex ¶
RenameIndex renames an index in the database.
type NestedArrayType ¶ added in v0.5.2
type NestedArrayType struct { ElementType string `json:"element_type"` // Type of elements (STRUCT, MAP, etc.) Elements []interface{} `json:"elements"` // Array elements Dimensions int `json:"dimensions"` // Number of array dimensions }
NestedArrayType represents advanced nested array operations (arrays of complex types)
func NewNestedArray ¶ added in v0.5.2
func NewNestedArray(elementType string, elements []interface{}, dimensions int) NestedArrayType
NewNestedArray creates a new NestedArrayType
func (NestedArrayType) Get ¶ added in v0.5.2
func (n NestedArrayType) Get(index int) (interface{}, error)
Get returns the element at the specified index
func (NestedArrayType) GormDataType ¶ added in v0.5.2
func (n NestedArrayType) GormDataType() string
GormDataType implements the GormDataTypeInterface for NestedArrayType
func (NestedArrayType) Length ¶ added in v0.5.2
func (n NestedArrayType) Length() int
Length returns the number of elements in the array
func (*NestedArrayType) Scan ¶ added in v0.5.2
func (n *NestedArrayType) Scan(value interface{}) error
Scan implements sql.Scanner interface for NestedArrayType
func (NestedArrayType) Slice ¶ added in v0.5.2
func (n NestedArrayType) Slice(start, end int) (NestedArrayType, error)
Slice returns a slice of the array from start to end
type PerformanceMetricsType ¶ added in v0.5.2
type PerformanceMetricsType struct { QueryTime float64 `json:"query_time"` // Execution time in milliseconds MemoryUsage int64 `json:"memory_usage"` // Memory usage in bytes RowsScanned int64 `json:"rows_scanned"` // Number of rows scanned RowsReturned int64 `json:"rows_returned"` // Number of rows returned Metrics map[string]interface{} `json:"metrics"` // Additional performance metrics }
PerformanceMetricsType represents DuckDB performance and profiling information
func NewPerformanceMetrics ¶ added in v0.5.2
func NewPerformanceMetrics() PerformanceMetricsType
NewPerformanceMetrics creates a new PerformanceMetricsType
func (*PerformanceMetricsType) AddMetric ¶ added in v0.5.2
func (p *PerformanceMetricsType) AddMetric(key string, value interface{})
AddMetric adds a custom performance metric
func (PerformanceMetricsType) GetMetric ¶ added in v0.5.2
func (p PerformanceMetricsType) GetMetric(key string) (interface{}, bool)
GetMetric retrieves a custom performance metric
func (PerformanceMetricsType) GormDataType ¶ added in v0.5.2
func (PerformanceMetricsType) GormDataType() string
GormDataType implements the GormDataTypeInterface for PerformanceMetricsType
func (*PerformanceMetricsType) Scan ¶ added in v0.5.2
func (p *PerformanceMetricsType) Scan(value interface{}) error
Scan implements sql.Scanner interface for PerformanceMetricsType
func (PerformanceMetricsType) Summary ¶ added in v0.5.2
func (p PerformanceMetricsType) Summary() string
Summary returns a formatted summary of performance metrics
type QueryHintType ¶ added in v0.5.2
type QueryHintType struct { HintType string `json:"hint_type"` // Type of hint (INDEX, PARTITION, etc.) Options map[string]interface{} `json:"options"` // Hint options and parameters }
QueryHintType represents DuckDB query optimization hints
func NewQueryHint ¶ added in v0.5.2
func NewQueryHint(hintType string, options map[string]interface{}) QueryHintType
NewQueryHint creates a new QueryHintType
func (QueryHintType) GormDataType ¶ added in v0.5.2
func (QueryHintType) GormDataType() string
GormDataType implements the GormDataTypeInterface for QueryHintType
func (*QueryHintType) Scan ¶ added in v0.5.2
func (q *QueryHintType) Scan(value interface{}) error
Scan implements sql.Scanner interface for QueryHintType
func (QueryHintType) ToSQL ¶ added in v0.5.2
func (q QueryHintType) ToSQL() string
ToSQL generates the SQL hint syntax
type SimpleArrayScanner ¶
type SimpleArrayScanner struct {
Target interface{} // Pointer to slice
}
SimpleArrayScanner provides basic array scanning functionality
func (*SimpleArrayScanner) Scan ¶
func (sas *SimpleArrayScanner) Scan(value interface{}) error
Scan implements sql.Scanner for basic array types
type StringArray ¶
type StringArray []string
StringArray represents a DuckDB TEXT[] array type
func (StringArray) GormDataType ¶
func (StringArray) GormDataType() string
GormDataType implements the GormDataTypeInterface for StringArray
func (*StringArray) Scan ¶
func (a *StringArray) Scan(value interface{}) error
Scan implements sql.Scanner interface for StringArray
type StructType ¶ added in v0.5.2
type StructType map[string]interface{}
StructType represents a DuckDB STRUCT type - complex nested data with named fields
func (StructType) GormDataType ¶ added in v0.5.2
func (StructType) GormDataType() string
GormDataType implements the GormDataTypeInterface for StructType
func (*StructType) Scan ¶ added in v0.5.2
func (s *StructType) Scan(value interface{}) error
Scan implements sql.Scanner interface for StructType
type TimestampTZType ¶ added in v0.5.2
type TimestampTZType struct { Time time.Time `json:"time"` // The timestamp Location *time.Location `json:"location"` // Timezone information }
TimestampTZType represents a DuckDB TIMESTAMPTZ (timestamp with timezone)
func NewTimestampTZ ¶ added in v0.5.2
func NewTimestampTZ(t time.Time, location *time.Location) TimestampTZType
NewTimestampTZ creates a new TimestampTZType
func (TimestampTZType) GormDataType ¶ added in v0.5.2
func (TimestampTZType) GormDataType() string
GormDataType implements the GormDataTypeInterface for TimestampTZType
func (TimestampTZType) In ¶ added in v0.5.2
func (t TimestampTZType) In(loc *time.Location) TimestampTZType
In returns the timestamp in the specified timezone
func (*TimestampTZType) Scan ¶ added in v0.5.2
func (t *TimestampTZType) Scan(value interface{}) error
Scan implements sql.Scanner interface for TimestampTZType
func (TimestampTZType) UTC ¶ added in v0.5.2
func (t TimestampTZType) UTC() time.Time
UTC returns the timestamp in UTC
type UNIONType ¶ added in v0.5.2
type UNIONType struct { Types []string `json:"types"` // Allowed type names Data interface{} `json:"data"` // Current value TypeName string `json:"type_name"` // Active type name }
UNIONType represents a DuckDB UNION type that can hold values of different types
func (UNIONType) GormDataType ¶ added in v0.5.2
GormDataType implements the GormDataTypeInterface for UNIONType
type UUIDType ¶ added in v0.5.2
type UUIDType struct {
Data string // Store UUID as string
}
UUIDType represents a DuckDB UUID type
func (UUIDType) GormDataType ¶ added in v0.5.2
GormDataType implements the GormDataTypeInterface for UUIDType