storage

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TryConvertValue added in v1.0.0

func TryConvertValue(value any, expectedType DataType) (any, bool)

TryConvertValue attempts to convert a value to the expected type Returns (convertedValue, success). If conversion fails, returns (nil, false)

Types

type ColumnDef added in v1.0.0

type ColumnDef struct {
	Name string
	Type DataType
}

ColumnDef defines a column with its name and inferred type

func InferColumnTypes added in v1.0.0

func InferColumnTypes(columns []string, sampleRows [][]any) []ColumnDef

InferColumnTypes analyzes sample data to infer the best type for each column It uses the most restrictive type that can represent all values: BIGINT -> DOUBLE -> VARCHAR (BOOLEAN is special-cased)

type DataType added in v1.0.0

type DataType string

DataType represents the detected type of a column

const (
	TypeVarchar DataType = "VARCHAR"
	TypeBigInt  DataType = "BIGINT"
	TypeDouble  DataType = "DOUBLE"
	TypeBoolean DataType = "BOOLEAN"
)

func InferType added in v1.0.0

func InferType(value any) DataType

InferType detects the most appropriate data type for a value

type Storage

type Storage interface {
	BuildStructure(string, []string) error
	InsertRow(string, []string, []any) error
	Query(cmd string) (*sql.Rows, error)
	ShowTables() (*sql.Rows, error)
	Close() error
}

Storage is the main interface for data storage operations

type TypedStorage added in v1.0.0

type TypedStorage interface {
	Storage
	BuildStructureWithTypes(tableName string, columns []ColumnDef) error
	InsertRowWithCoercion(tableName string, columns []string, values []any, columnDefs []ColumnDef) error
}

TypedStorage is an optional interface for storage implementations that support typed columns for better query compatibility

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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