hrana

package
v0.0.0-...-1956c2a Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	Steps []BatchStep `json:"steps"`
}

func (*Batch) Add

func (b *Batch) Add(stmt Stmt)

type BatchCondition

type BatchCondition struct {
	Type  string           `json:"type"`
	Step  *int32           `json:"step,omitempty"`
	Cond  *BatchCondition  `json:"cond,omitempty"`
	Conds []BatchCondition `json:"conds,omitempty"`
}

type BatchResult

type BatchResult struct {
	StepResults []*StmtResult `json:"step_results"`
	StepErrors  []*Error      `json:"step_errors"`
}

type BatchStep

type BatchStep struct {
	Stmt      Stmt            `json:"stmt"`
	Condition *BatchCondition `json:"condition,omitempty"`
}

type Column

type Column struct {
	Name *string `json:"name"`
	Type *string `json:"decltype"`
}

type Error

type Error struct {
	Message string  `json:"message"`
	Code    *string `json:"code,omitempty"`
}

type NamedArg

type NamedArg struct {
	Name  string `json:"name"`
	Value Value  `json:"value"`
}

type PipelineRequest

type PipelineRequest struct {
	Baton    string          `json:"baton,omitempty"`
	Requests []StreamRequest `json:"requests"`
}

func (*PipelineRequest) Add

func (pr *PipelineRequest) Add(request StreamRequest)

type PipelineResponse

type PipelineResponse struct {
	Baton   string         `json:"baton,omitempty"`
	BaseUrl string         `json:"base_url,omitempty"`
	Results []StreamResult `json:"results"`
}

type Stmt

type Stmt struct {
	Sql       *string    `json:"sql,omitempty"`
	SqlId     *int32     `json:"sql_id,omitempty"`
	Args      []Value    `json:"args,omitempty"`
	NamedArgs []NamedArg `json:"named_args,omitempty"`
	WantRows  bool       `json:"want_rows"`
}

func (*Stmt) AddArgs

func (s *Stmt) AddArgs(params shared.Params) error

func (*Stmt) AddNamedArgs

func (s *Stmt) AddNamedArgs(args map[string]any) error

func (*Stmt) AddPositionalArgs

func (s *Stmt) AddPositionalArgs(args []any) error

type StmtResult

type StmtResult struct {
	Cols             []Column  `json:"cols"`
	Rows             [][]Value `json:"rows"`
	AffectedRowCount int32     `json:"affected_row_count"`
	LastInsertRowId  *string   `json:"last_insert_rowid"`
}

func (*StmtResult) GetLastInsertRowId

func (r *StmtResult) GetLastInsertRowId() int64

type StreamRequest

type StreamRequest struct {
	Type  string  `json:"type"`
	Stmt  *Stmt   `json:"stmt,omitempty"`
	Batch *Batch  `json:"batch,omitempty"`
	Sql   *string `json:"sql,omitempty"`
	SqlId *int32  `json:"sql_id,omitempty"`
}

func BatchStream

func BatchStream(sqls []string, params []shared.Params, wantRows bool) (*StreamRequest, error)

func CloseStoredSqlStream

func CloseStoredSqlStream(sqlId int32) StreamRequest

func CloseStream

func CloseStream() StreamRequest

func ExecuteStoredStream

func ExecuteStoredStream(sqlId int32, params shared.Params, wantRows bool) (*StreamRequest, error)

func ExecuteStream

func ExecuteStream(sql string, params shared.Params, wantRows bool) (*StreamRequest, error)

func StoreSqlStream

func StoreSqlStream(sql string, sqlId int32) StreamRequest

type StreamResponse

type StreamResponse struct {
	Type   string          `json:"type"`
	Result json.RawMessage `json:"result,omitempty"`
}

func (*StreamResponse) BatchResult

func (r *StreamResponse) BatchResult() (*BatchResult, error)

func (*StreamResponse) ExecuteResult

func (r *StreamResponse) ExecuteResult() (*StmtResult, error)

type StreamResult

type StreamResult struct {
	Type     string          `json:"type"`
	Response *StreamResponse `json:"response,omitempty"`
	Error    *Error          `json:"error,omitempty"`
}

type Value

type Value struct {
	Type   string `json:"type"`
	Value  any    `json:"value,omitempty"`
	Base64 string `json:"base64,omitempty"`
}

func ToValue

func ToValue(v any) (Value, error)

func (Value) ToValue

func (v Value) ToValue(columnType *string) any

Jump to

Keyboard shortcuts

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