sql

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

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

Type string for generic sql QuadStore.

Deprecated: use specific types from sub-packages.

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) Clone

func (it *Iterator) Clone() graph.Iterator

func (*Iterator) Close

func (it *Iterator) Close() error

func (*Iterator) Contains

func (it *Iterator) Contains(ctx context.Context, v graph.Value) bool

func (*Iterator) Err

func (it *Iterator) Err() error

func (*Iterator) Next

func (it *Iterator) Next(ctx context.Context) bool

func (*Iterator) NextPath

func (it *Iterator) NextPath(ctx context.Context) bool

func (*Iterator) Optimize

func (it *Iterator) Optimize() (graph.Iterator, bool)

func (*Iterator) Reset

func (it *Iterator) Reset()

func (*Iterator) Result

func (it *Iterator) Result() graph.Value

func (*Iterator) Size

func (it *Iterator) Size() (int64, bool)

func (*Iterator) Stats

func (it *Iterator) Stats() graph.IteratorStats

func (*Iterator) String

func (it *Iterator) String() string

func (*Iterator) SubIterators

func (it *Iterator) SubIterators() []graph.Iterator

func (*Iterator) TagResults

func (it *Iterator) TagResults(m map[string]graph.Value)

func (*Iterator) Tagger

func (it *Iterator) Tagger() *graph.Tagger

func (*Iterator) Type

func (it *Iterator) Type() graph.Type

func (*Iterator) UID

func (it *Iterator) UID() uint64

type NodeHash

type NodeHash struct {
	graph.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(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 {
	graph.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.Value) quad.Value

func (*QuadStore) NewIterator

func (qs *QuadStore) NewIterator(s Select) *Iterator

func (*QuadStore) NodesAllIterator

func (qs *QuadStore) NodesAllIterator() graph.Iterator

func (*QuadStore) OptimizeIterator

func (qs *QuadStore) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool)

func (*QuadStore) OptimizeShape

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

func (*QuadStore) Quad

func (qs *QuadStore) Quad(val graph.Value) quad.Quad

func (*QuadStore) QuadDirection

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

func (*QuadStore) QuadIterator

func (qs *QuadStore) QuadIterator(d quad.Direction, val graph.Value) graph.Iterator

func (*QuadStore) QuadsAllIterator

func (qs *QuadStore) QuadsAllIterator() graph.Iterator

func (*QuadStore) Query

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

func (*QuadStore) Size

func (qs *QuadStore) Size() int64

func (*QuadStore) ValueOf

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

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
}

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) graph.Iterator

func (Select) Clone

func (s Select) Clone() Select

func (Select) Columns

func (s Select) Columns() []string

func (Select) Optimize

func (s Select) Optimize(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