spanvalue

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: MIT Imports: 16 Imported by: 1

README

spanvalue

This package includes spanner.GenericValueColumn related functionality.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFallthrough = errors.New("fallthrough")
View Source
var FormatTypedStruct = FormatStruct{
	FormatStructParen: formatTypedStructParen,
	FormatStructField: formatSimpleStructField,
}
View Source
var LiteralFormatConfig = &FormatConfig{
	NullString:     nullStringUpperCase,
	FormatArray:    FormatOptionallyTypedArray,
	FormatStruct:   FormatTypedStruct,
	FormatNullable: formatNullableValueLiteral,
	FormatComplexPlugins: []FormatComplexFunc{
		FormatProtoAsCast,
		FormatEnumAsCast,
	},
}
View Source
var SimpleFormatConfig = FormatConfig{
	NullString:  nullStringClientLib,
	FormatArray: FormatUntypedArray,
	FormatStruct: FormatStruct{
		FormatStructField: FormatTypelessStructField,
		FormatStructParen: FormatTupleStruct,
	},
	FormatNullable: formatNullableValueSimple,
}
View Source
var SpannerCLICompatibleFormatConfig = FormatConfig{
	NullString:  nullStringUpperCase,
	FormatArray: FormatUntypedArray,
	FormatStruct: FormatStruct{
		FormatStructField: FormatSimpleStructField,
		FormatStructParen: FormatBracketStruct,
	},
	FormatNullable: FormatNullableSpannerCLICompatible,
}

Functions

func FormatBracketStruct

func FormatBracketStruct(typ *sppb.Type, toplevel bool, fieldStrings []string) string

func FormatColumnLiteral

func FormatColumnLiteral(value spanner.GenericColumnValue) (string, error)

func FormatColumnSpannerCLICompatible

func FormatColumnSpannerCLICompatible(value spanner.GenericColumnValue) (string, error)

func FormatEnumAsCast

func FormatEnumAsCast(formatter Formatter, value spanner.GenericColumnValue, toplevel bool) (string, error)

func FormatNullableSpannerCLICompatible

func FormatNullableSpannerCLICompatible(value NullableValue) (string, error)

func FormatOptionallyTypedArray

func FormatOptionallyTypedArray(typ *sppb.Type, toplevel bool, elemStrings []string) string

func FormatProtoAsCast

func FormatProtoAsCast(formatter Formatter, value spanner.GenericColumnValue, toplevel bool) (string, error)

func FormatRowLiteral

func FormatRowLiteral(value *spanner.Row) ([]string, error)

func FormatRowSpannerCLICompatible

func FormatRowSpannerCLICompatible(row *spanner.Row) ([]string, error)

func FormatSimpleStructField

func FormatSimpleStructField(fc *FormatConfig, field *sppb.StructType_Field, value *structpb.Value) (string, error)

func FormatTupleStruct

func FormatTupleStruct(typ *sppb.Type, toplevel bool, fieldStrings []string) string

func FormatTypelessStructField

func FormatTypelessStructField(fc *FormatConfig, field *sppb.StructType_Field, value *structpb.Value) (string, error)

func FormatUntypedArray

func FormatUntypedArray(typ *sppb.Type, toplevel bool, elemStrings []string) string

Types

type FormatArrayFunc

type FormatArrayFunc func(typ *sppb.Type, toplevel bool, elemStrings []string) string

type FormatComplexFunc

type FormatComplexFunc = func(formatter Formatter, value spanner.GenericColumnValue, toplevel bool) (string, error)

FormatComplexFunc is a function to format spanner.GenericColumnValue. If it returns ErrFallthrough, value will pass through to next step.

type FormatConfig

type FormatConfig struct {
	NullString           string
	FormatArray          FormatArrayFunc
	FormatStruct         FormatStruct
	FormatComplexPlugins []FormatComplexFunc
	FormatNullable       FormatNullableFunc
}

func (*FormatConfig) FormatColumn

func (fc *FormatConfig) FormatColumn(value spanner.GenericColumnValue, toplevel bool) (string, error)

func (*FormatConfig) FormatRow

func (fc *FormatConfig) FormatRow(row *spanner.Row) ([]string, error)

func (*FormatConfig) FormatToplevelColumn

func (fc *FormatConfig) FormatToplevelColumn(value spanner.GenericColumnValue) (string, error)

type FormatNullableFunc

type FormatNullableFunc = func(value NullableValue) (string, error)

type FormatStruct

type FormatStruct struct {
	FormatStructField FormatStructFieldFunc
	FormatStructParen FormatStructParenFunc
}

type FormatStructFieldFunc

type FormatStructFieldFunc func(fc *FormatConfig, field *sppb.StructType_Field, value *structpb.Value) (string, error)

type FormatStructParenFunc

type FormatStructParenFunc func(typ *sppb.Type, toplevel bool, fieldStrings []string) string

type Formatter

type Formatter interface {
	FormatColumn(value spanner.GenericColumnValue, toplevel bool) (string, error)
}

type NullBytes

type NullBytes []byte

func (NullBytes) IsNull

func (n NullBytes) IsNull() bool

func (NullBytes) String

func (n NullBytes) String() string

type NullableValue

type NullableValue interface {
	spanner.NullableValue
	fmt.Stringer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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