sql

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	OpEqual  = CmpOp("=")
	OpGT     = CmpOp(">")
	OpGTE    = CmpOp(">=")
	OpLT     = CmpOp("<")
	OpLTE    = CmpOp("<=")
	OpIsNull = CmpOp("IS NULL")
	OpIsTrue = CmpOp("IS true")
)

Variables

View Source
var DefaultDialect = QueryDialect{
	FieldQuote: func(s string) string {
		return strconv.Quote(s)
	},
	Placeholder: func(_ int) string {
		return "?"
	},
}

Functions

func Init

func Init(typ string, addr string, options graph.Options) error

func New

func New(typ string, addr string, options graph.Options) (graph.QuadStore, error)

func Register

func Register(name string, f Registration)

Types

type BoolVal

type BoolVal bool

func (BoolVal) SQLValue

func (v BoolVal) SQLValue() interface{}

type Builder

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

func NewBuilder

func NewBuilder(d QueryDialect) *Builder

func (*Builder) EscapeField

func (b *Builder) EscapeField(s string) string

func (*Builder) Placeholder

func (b *Builder) Placeholder() string

type CmpOp

type CmpOp string

type Expr

type Expr interface {
	SQL(b *Builder) string
	// contains filtered or unexported methods
}

type Field

type Field struct {
	Name  string
	Raw   bool // do not quote Name
	Alias string
	Table string
}

func (Field) NameOrAlias

func (f Field) NameOrAlias() string

func (Field) SQL

func (f Field) SQL(b *Builder) string

type FieldName

type FieldName struct {
	Name  string
	Table string
}

func (FieldName) SQL

func (f FieldName) SQL(b *Builder) string

type FloatVal

type FloatVal float64

func (FloatVal) SQLValue

func (v FloatVal) SQLValue() interface{}

type IntVal

type IntVal int64

func (IntVal) SQLValue

func (v IntVal) SQLValue() interface{}

type Iterator

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

func (*Iterator) Iterate

func (it *Iterator) Iterate() iterator.Scanner

func (*Iterator) Lookup

func (it *Iterator) Lookup() iterator.Index

func (*Iterator) Optimize

func (it *Iterator) Optimize(ctx context.Context) (iterator.Shape, bool)

func (*Iterator) Stats

func (it *Iterator) Stats(ctx context.Context) (iterator.Costs, error)

func (*Iterator) String

func (it *Iterator) String() string

func (*Iterator) SubIterators

func (it *Iterator) SubIterators() []iterator.Shape

type NodeHash

type NodeHash struct {
	refs.ValueHash
}

func HashOf

func HashOf(s quad.Value) NodeHash

func (NodeHash) SQLValue

func (h NodeHash) SQLValue() interface{}

func (*NodeHash) Scan

func (h *NodeHash) Scan(src interface{}) error

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

NullTime represents a time.Time that may be null. NullTime implements the sql.Scanner interface so it can be used as a scan destination, similar to sql.NullString.

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Optimizer

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

func NewOptimizer

func NewOptimizer() *Optimizer

func (*Optimizer) NoOffsetWithoutLimit

func (opt *Optimizer) NoOffsetWithoutLimit()

func (*Optimizer) OptimizeShape

func (opt *Optimizer) OptimizeShape(ctx context.Context, s shape.Shape) (shape.Shape, bool)

func (*Optimizer) SetRegexpOp

func (opt *Optimizer) SetRegexpOp(op CmpOp)

type Placeholder

type Placeholder struct{}

func (Placeholder) SQL

func (Placeholder) SQL(b *Builder) string

type QuadHashes

type QuadHashes struct {
	refs.QuadHash
}

type QuadStore

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

func (*QuadStore) ApplyDeltas

func (qs *QuadStore) ApplyDeltas(in []graph.Delta, opts graph.IgnoreOpts) error

func (*QuadStore) Close

func (qs *QuadStore) Close() error

func (*QuadStore) NameOf

func (qs *QuadStore) NameOf(v graph.Ref) (quad.Value, error)

func (*QuadStore) NewQuadWriter

func (qs *QuadStore) NewQuadWriter() (quad.WriteCloser, error)

func (*QuadStore) NodesAllIterator

func (qs *QuadStore) NodesAllIterator() iterator.Shape

func (*QuadStore) OptimizeShape

func (qs *QuadStore) OptimizeShape(ctx context.Context, s shape.Shape) (shape.Shape, bool)

func (*QuadStore) Quad

func (qs *QuadStore) Quad(val graph.Ref) (quad.Quad, error)

func (*QuadStore) QuadDirection

func (qs *QuadStore) QuadDirection(in graph.Ref, d quad.Direction) (graph.Ref, error)

func (*QuadStore) QuadIterator

func (qs *QuadStore) QuadIterator(d quad.Direction, val graph.Ref) iterator.Shape

func (*QuadStore) QuadIteratorSize

func (qs *QuadStore) QuadIteratorSize(ctx context.Context, d quad.Direction, val graph.Ref) (refs.Size, error)

func (*QuadStore) QuadsAllIterator

func (qs *QuadStore) QuadsAllIterator() iterator.Shape

func (*QuadStore) Query

func (qs *QuadStore) Query(ctx context.Context, s Shape) (*sql.Rows, error)

func (*QuadStore) QueryRow

func (qs *QuadStore) QueryRow(ctx context.Context, s Shape) *sql.Row

func (*QuadStore) Stats

func (qs *QuadStore) Stats(ctx context.Context, exact bool) (graph.Stats, error)

func (*QuadStore) ValueOf

func (qs *QuadStore) ValueOf(s quad.Value) (graph.Ref, error)

type QueryDialect

type QueryDialect struct {
	RegexpOp    CmpOp
	FieldQuote  func(string) string
	Placeholder func(int) string
}

type Registration

type Registration struct {
	Driver             string // sql driver to use on dial
	HashType           string // type for hash fields
	BytesType          string // type for binary fields
	TimeType           string // type for datetime fields
	HorizonType        string // type for horizon counter
	NodesTableExtra    string // extra SQL to append to nodes table definition
	ConditionalIndexes bool   // database supports conditional indexes
	FillFactor         bool   // database supports fill percent on indexes
	NoForeignKeys      bool   // database has no support for FKs

	QueryDialect
	NoOffsetWithoutLimit bool // SELECT ... OFFSET can be used only with LIMIT

	Error               func(error) error         // error conversion function
	Estimated           func(table string) string // query that string that returns an estimated number of rows in table
	RunTx               func(tx *sql.Tx, nodes []graphlog.NodeUpdate, quads []graphlog.QuadUpdate, opts graph.IgnoreOpts) error
	TxRetry             func(tx *sql.Tx, stmts func() error) error
	NoSchemaChangesInTx bool
}

type Select

type Select struct {
	Fields []Field
	From   []Source
	Where  []Where
	Params []Value
	Limit  int64
	Offset int64
	// contains filtered or unexported fields
}

Select is a simplified representation of SQL SELECT query.

func AllNodes

func AllNodes() Select

func AllQuads

func AllQuads(alias string) Select

func Nodes

func Nodes(where []Where, params []Value) Select

func SelectValue

func SelectValue(v quad.Value, op CmpOp) *Select

func (*Select) AppendParam

func (s *Select) AppendParam(o Value) Expr

func (Select) Args

func (s Select) Args() []Value

func (Select) BuildIterator

func (s Select) BuildIterator(qs graph.QuadStore) iterator.Shape

func (Select) Clone

func (s Select) Clone() Select

func (Select) Columns

func (s Select) Columns() []string

func (Select) Optimize

func (s Select) Optimize(ctx context.Context, r shape.Optimizer) (shape.Shape, bool)

func (Select) SQL

func (s Select) SQL(b *Builder) string

func (*Select) WhereEq

func (s *Select) WhereEq(tbl, field string, v Value)

type Shape

type Shape interface {
	SQL(b *Builder) string
	Args() []Value
	Columns() []string
}

type Source

type Source interface {
	SQL(b *Builder) string
	Args() []Value
	// contains filtered or unexported methods
}

type StringVal

type StringVal string

func (StringVal) SQLValue

func (v StringVal) SQLValue() interface{}

type Subquery

type Subquery struct {
	Query Select
	Alias string
}

func (Subquery) Args

func (s Subquery) Args() []Value

func (Subquery) SQL

func (s Subquery) SQL(b *Builder) string

type Table

type Table struct {
	Name  string
	Alias string
}

func (Table) Args

func (f Table) Args() []Value

func (Table) NameSQL

func (f Table) NameSQL() string

func (Table) SQL

func (f Table) SQL(b *Builder) string

type TimeVal

type TimeVal time.Time

func (TimeVal) SQLValue

func (v TimeVal) SQLValue() interface{}

type Value

type Value interface {
	SQLValue() interface{}
}

type ValueType

type ValueType int

func NodeValues

func NodeValues(h NodeHash, v quad.Value) (ValueType, []interface{}, error)

func (ValueType) Columns

func (t ValueType) Columns() []string

type Where

type Where struct {
	Field string
	Table string
	Op    CmpOp
	Value Expr
}

func (Where) SQL

func (w Where) SQL(b *Builder) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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