encoding

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTypesColumnsLengthViolation is returned when a results
	// object doesn't have the same number of types and columns
	ErrTypesColumnsLengthViolation = errors.New("types and columns are different lengths")
)

Functions

func NewAssociativeResultRowsFromExecuteQueryResponse

func NewAssociativeResultRowsFromExecuteQueryResponse(e *proto.ExecuteQueryResponse, bytesAsArray bool) (interface{}, error)

func NewResultRowsFromExecuteQueryResponse

func NewResultRowsFromExecuteQueryResponse(e *proto.ExecuteQueryResponse, bytesAsArray bool) (interface{}, error)

NewResultRowsFromExecuteQueryResponse returns an API object from an ExecuteQueryResponse.

func NewValuesFromQueryValues

func NewValuesFromQueryValues(dest [][]interface{}, v []*proto.Values, bytesAsArray bool) error

NewValuesFromQueryValues sets Values from a QueryValue object.

Types

type AssociativeRows

type AssociativeRows struct {
	Types map[string]string        `json:"types,omitempty"`
	Rows  []map[string]interface{} `json:"rows"`
	Error string                   `json:"error,omitempty"`
	Time  float64                  `json:"time,omitempty"`
}

AssociativeRows represents the outcome of an operation that returns query data.

func NewAssociativeRowsFromQueryRows

func NewAssociativeRowsFromQueryRows(q *proto.QueryRows, bytesAsArray bool) (*AssociativeRows, error)

NewAssociativeRowsFromQueryRows returns an associative API object from a QueryRows

type ByteSliceAsArray

type ByteSliceAsArray []byte

ByteSliceAsArray is a byte slice that marshals to a JSON array of integers.

func (ByteSliceAsArray) MarshalJSON

func (b ByteSliceAsArray) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. It marshals the byte slice as an array of integers.

type Encoder

type Encoder struct {
	Associative       bool
	BlobsAsByteArrays bool
}

Encoder is used to JSON marshal ExecuteResults, QueryRows and ExecuteQueryRequests.

func (*Encoder) JSONMarshal

func (e *Encoder) JSONMarshal(i interface{}) ([]byte, error)

JSONMarshal implements the marshal interface

func (*Encoder) JSONMarshalIndent

func (e *Encoder) JSONMarshalIndent(i interface{}, prefix, indent string) ([]byte, error)

JSONMarshalIndent implements the marshal indent interface

type Result

type Result struct {
	LastInsertID int64   `json:"last_insert_id,omitempty"`
	RowsAffected int64   `json:"rows_affected,omitempty"`
	Error        string  `json:"error,omitempty"`
	Time         float64 `json:"time,omitempty"`
}

Result represents the outcome of an operation that changes rows.

func NewResultFromExecuteResult

func NewResultFromExecuteResult(e *proto.ExecuteResult) (*Result, error)

NewResultFromExecuteResult returns an API Result object from an ExecuteResult.

type ResultWithRows

type ResultWithRows struct {
	Result
	Rows []map[string]interface{} `json:"rows"`
}

ResultWithRows represents the outcome of an operation that changes rows, but also includes an nil rows object, so clients can distinguish between a query and execute result.

type Rows

type Rows struct {
	Columns []string        `json:"columns,omitempty"`
	Types   []string        `json:"types,omitempty"`
	Values  [][]interface{} `json:"values,omitempty"`
	Error   string          `json:"error,omitempty"`
	Time    float64         `json:"time,omitempty"`
}

Rows represents the outcome of an operation that returns query data.

func NewRowsFromQueryRows

func NewRowsFromQueryRows(q *proto.QueryRows, bytesAsArray bool) (*Rows, error)

NewRowsFromQueryRows returns an API Rows object from a QueryRows

Jump to

Keyboard shortcuts

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