server

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBDTInteger dbDataType = "INTEGER"
	DBDTReal    dbDataType = "REAL"
	DBDTText    dbDataType = "TEXT"
	DBDTBlob    dbDataType = "BLOB"
	DBDTJson    dbDataType = "JSON"
)
View Source
const SqliteArgumentRuntimeErrorPrefix = "_sqlite_argument_runtime_error_: "
View Source
const SqliteOutOfRangeRuntimeErrorPrefix = "_sqlite_ooo_runtime_error_: "

Variables

View Source
var (
	ErrNotStartedTransaction   = fmt.Errorf("transaction is not started")
	ErrNotAvailableTransaction = fmt.Errorf("transaction is not available")
	ErrInvalidatedTransaction  = fmt.Errorf("transaction is invalidated")
)
View Source
var NullExpr = Expr{}
View Source
var NullValue = Value{}

Functions

func BuildDML added in v0.4.0

func BuildDML(db *database, tx *transaction, dml ast.DML, params map[string]Value) (string, []interface{}, error)

func DebugStartEnd added in v0.4.0

func DebugStartEnd(format string, args ...interface{}) func()

func Debugf added in v0.4.0

func Debugf(format string, args ...interface{})

func IsDebug added in v0.4.0

func IsDebug() bool

func QuoteString added in v0.5.0

func QuoteString(s string) string

func QuoteStringSlice added in v0.5.0

func QuoteStringSlice(ss []string) []string

Types

type ArrayValue

type ArrayValue interface {
	Elements() interface{}
}

type ArrayValueDecoder added in v0.2.0

type ArrayValueDecoder struct {
	Values  interface{}
	Type    ValueType
	Invalid bool `json:"-"`
}

func (*ArrayValueDecoder) Scan added in v0.2.0

func (a *ArrayValueDecoder) Scan(src interface{}) error

func (*ArrayValueDecoder) UnmarshalJSON added in v0.2.0

func (a *ArrayValueDecoder) UnmarshalJSON(b []byte) error

func (*ArrayValueDecoder) Value added in v0.2.0

func (a *ArrayValueDecoder) Value() interface{}

type ArrayValueEncoder added in v0.2.0

type ArrayValueEncoder struct {
	Values  interface{}
	Invalid bool
}

func (*ArrayValueEncoder) Elements added in v0.2.0

func (a *ArrayValueEncoder) Elements() interface{}

func (*ArrayValueEncoder) Value added in v0.2.0

func (a *ArrayValueEncoder) Value() (driver.Value, error)

type BoolDecoder added in v0.2.0

type BoolDecoder struct {
	Bool *bool
}

func (*BoolDecoder) UnmarshalJSON added in v0.2.0

func (b *BoolDecoder) UnmarshalJSON(data []byte) error

type Column

type Column struct {
	// contains filtered or unexported fields
}

func (*Column) Alias

func (c *Column) Alias() string

func (*Column) Name

func (c *Column) Name() string

type CustomFunction

type CustomFunction struct {
	Name       string
	Func       interface{}
	NArgs      int
	ArgTypes   func([]ValueType) bool
	ReturnType func([]ValueType) ValueType
}

type Database

type Database interface {
	ApplyDDL(ctx context.Context, ddl ast.DDL) error

	Read(ctx context.Context, tx *transaction, tbl, index string, cols []string, keyset *KeySet, limit int64) (RowIterator, error)
	Query(ctx context.Context, tx *transaction, query *ast.QueryStatement, params map[string]Value) (RowIterator, error)
	Execute(ctx context.Context, tx *transaction, dml ast.DML, params map[string]Value) (int64, error)

	Insert(ctx context.Context, tx *transaction, tbl string, cols []string, values []*structpb.ListValue) error
	Update(ctx context.Context, tx *transaction, tbl string, cols []string, values []*structpb.ListValue) error
	Replace(ctx context.Context, tx *transaction, tbl string, cols []string, values []*structpb.ListValue) error
	InsertOrUpdate(ctx context.Context, tx *transaction, tbl string, cols []string, values []*structpb.ListValue) error
	Delete(ctx context.Context, tx *transaction, table string, keyset *KeySet) error

	BeginTransaction(tx *transaction) error
	Commit(tx *transaction) error
	Rollback(tx *transaction) error

	Close() error
}

type Expr

type Expr struct {
	Raw       string
	ValueType ValueType
	Args      []interface{}
}

type FakeSpannerServer

type FakeSpannerServer interface {
	ApplyDDL(ctx context.Context, databaseName string, stmt ast.DDL) error

	spannerpb.SpannerServer
	adminv1pb.DatabaseAdminServer
	lropb.OperationsServer
}

func NewFakeServer

func NewFakeServer() FakeSpannerServer

type KeyRange

type KeyRange struct {
	// contains filtered or unexported fields
}

type KeySet

type KeySet struct {
	All    bool
	Keys   []*structpb.ListValue
	Ranges []*KeyRange
}

type QueryBuilder

type QueryBuilder struct {
	// contains filtered or unexported fields
}

func (*QueryBuilder) Build

func (b *QueryBuilder) Build() (string, []interface{}, []ResultItem, error)

func (*QueryBuilder) BuildDML added in v0.4.0

func (b *QueryBuilder) BuildDML() (string, []interface{}, error)

type ResultItem

type ResultItem struct {
	Name      string
	ValueType ValueType

	Expr Expr
}

func BuildQuery

func BuildQuery(db *database, tx *transaction, stmt ast.QueryExpr, params map[string]Value, forceColumnAlias bool) (string, []interface{}, []ResultItem, error)

type RowIterator

type RowIterator interface {
	ResultSet() []ResultItem

	Do(func([]interface{}) error) error
}

type StructType

type StructType struct {
	FieldNames []string
	FieldTypes []*ValueType

	// Table can be struct but it behaves differently.
	// So a struct created from table should be marked.
	IsTable bool
}

func (*StructType) AllItems added in v0.2.0

func (s *StructType) AllItems() []ResultItem

type StructValue added in v0.2.0

type StructValue struct {
	Keys   []string      `json:"keys"`
	Values []interface{} `json:"values"`
}

type Table

type Table struct {
	Name string
	// contains filtered or unexported fields
}

func (*Table) NonNullableAndNonGeneratedColumnsExist added in v0.7.3

func (t *Table) NonNullableAndNonGeneratedColumnsExist(columns []string) (bool, []string)

NonNullableAndNonGeneratedColumnsExist checks non nullable columns exist in the spciefied columns. It returns true and the columns if non nullable and non generated columns exist.

func (*Table) TableIndex

func (t *Table) TableIndex(idx string) (*TableIndex, bool)

func (*Table) TableView

func (t *Table) TableView() *TableView

func (*Table) TableViewWithAlias added in v0.4.0

func (t *Table) TableViewWithAlias(alias string) *TableView

type TableIndex

type TableIndex struct {
	// contains filtered or unexported fields
}

func (*TableIndex) HasColumn

func (i *TableIndex) HasColumn(c string) bool

func (*TableIndex) IndexColumnDirections

func (i *TableIndex) IndexColumnDirections() []string

func (*TableIndex) IndexColumnNames

func (i *TableIndex) IndexColumnNames() []string

func (*TableIndex) IndexColumns

func (i *TableIndex) IndexColumns() []*Column

func (*TableIndex) Name

func (i *TableIndex) Name() string

type TableView

type TableView struct {
	ResultItems    []ResultItem
	ResultItemsMap map[string]ResultItem
	// contains filtered or unexported fields
}

func (*TableView) AllItems

func (v *TableView) AllItems() []ResultItem

func (*TableView) Get

func (v *TableView) Get(id string) (ResultItem, bool, bool)

func (*TableView) ToStruct added in v0.2.0

func (v *TableView) ToStruct() *StructType

type TransactionStatus added in v0.3.0

type TransactionStatus int
const (
	TransactionActive      TransactionStatus = 1
	TransactionInvalidated TransactionStatus = 2
	TransactionCommited    TransactionStatus = 3
	TransactionRollbacked  TransactionStatus = 4
	TransactionAborted     TransactionStatus = 5
)

func (TransactionStatus) String added in v0.4.0

func (s TransactionStatus) String() string

type TypeCode

type TypeCode int32
const (
	TCBool TypeCode = iota + 1
	TCInt64
	TCFloat64
	TCTimestamp
	TCDate
	TCString
	TCBytes
	TCArray
	TCStruct
	TCJson
)

func (TypeCode) String

func (c TypeCode) String() string

type Value

type Value struct {
	Data interface{}
	Type ValueType
}

type ValueType

type ValueType struct {
	Code       TypeCode
	ArrayType  *ValueType
	StructType *StructType
}

func (ValueType) IsArray

func (t ValueType) IsArray() bool

func (ValueType) IsStruct

func (t ValueType) IsStruct() bool

func (ValueType) String

func (t ValueType) String() string

Jump to

Keyboard shortcuts

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