coltypes

package
v0.0.0-...-69a6c05 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package coltypes implements functions for converting DB2 column types to appropriate Go types.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotConvertValueToBytes = errors.New("cannot convert value to byte slice")
	ErrValueIsNotAString         = errors.New("value is not a string")
	ErrConvertDecFloat           = errors.New("cannot convert DECFLOAT")
	ErrInvalidTimeLayout         = errors.New("invalid time layout")
)

Functions

func ConvertStructureData

func ConvertStructureData(
	_ context.Context,
	columnTypes map[string]string,
	data sdk.StructuredData,
) (sdk.StructuredData, error)

ConvertStructureData converts a sdk.StructureData values to a proper database types.

func TransformRow

func TransformRow(_ context.Context, row map[string]any, columnTypes map[string]string) (map[string]any, error)

TransformRow converts row map values to appropriate Go types, based on the columnTypes.

Types

type Querier

type Querier interface {
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
}

Querier is a database querier interface needed for the GetTableInfo function.

type TableInfo

type TableInfo struct {
	// ColumnTypes - column name with column type.
	ColumnTypes map[string]string
	// ColumnLengths - column name with length
	ColumnLengths map[string]int
	// PrimaryKeys - primary keys column names.
	PrimaryKeys []string
}

TableInfo - information about colum types, primary keys from table.

func GetTableInfo

func GetTableInfo(ctx context.Context, querier Querier, tableName string) (TableInfo, error)

GetTableInfo returns a map containing all table's columns and their database types and returns primary columns names.

func (TableInfo) GetCreateColumnStr

func (t TableInfo) GetCreateColumnStr() string

Jump to

Keyboard shortcuts

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