sql

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 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 added in v0.7.0

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

func New added in v0.7.0

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

func Register added in v0.7.0

func Register(name string, f Registration)

Types

type BoolVal added in v0.7.0

type BoolVal bool

func (BoolVal) SQLValue added in v0.7.0

func (v BoolVal) SQLValue() interface{}

type Builder added in v0.7.0

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

func NewBuilder added in v0.7.0

func NewBuilder(d QueryDialect) *Builder

func (*Builder) EscapeField added in v0.7.0

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

func (*Builder) Placeholder added in v0.7.0

func (b *Builder) Placeholder() string

type CmpOp added in v0.7.0

type CmpOp string

type Expr added in v0.7.0

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

type Field added in v0.7.0

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

func (Field) NameOrAlias added in v0.7.0

func (f Field) NameOrAlias() string

func (Field) SQL added in v0.7.0

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

type FieldName added in v0.7.0

type FieldName struct {
	Name  string
	Table string
}

func (FieldName) SQL added in v0.7.0

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

type FloatVal added in v0.7.0

type FloatVal float64

func (FloatVal) SQLValue added in v0.7.0

func (v FloatVal) SQLValue() interface{}

type IntVal added in v0.7.0

type IntVal int64

func (IntVal) SQLValue added in v0.7.0

func (v IntVal) SQLValue() interface{}

type Iterator added in v0.7.0

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

func (*Iterator) Clone added in v0.7.0

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

func (*Iterator) Close added in v0.7.0

func (it *Iterator) Close() error

func (*Iterator) Contains added in v0.7.0

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

func (*Iterator) Err added in v0.7.0

func (it *Iterator) Err() error

func (*Iterator) Next added in v0.7.0

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

func (*Iterator) NextPath added in v0.7.0

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

func (*Iterator) Optimize added in v0.7.0

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

func (*Iterator) Reset added in v0.7.0

func (it *Iterator) Reset()

func (*Iterator) Result added in v0.7.0

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

func (*Iterator) Size added in v0.7.0

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

func (*Iterator) Stats added in v0.7.0

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

func (*Iterator) String added in v0.7.0

func (it *Iterator) String() string

func (*Iterator) SubIterators added in v0.7.0

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

func (*Iterator) TagResults added in v0.7.0

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

func (*Iterator) Tagger added in v0.7.0

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

func (*Iterator) Type added in v0.7.0

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

func (*Iterator) UID added in v0.7.0

func (it *Iterator) UID() uint64

type NodeHash added in v0.6.0

type NodeHash struct {
	graph.ValueHash
}

func HashOf added in v0.7.0

func HashOf(s quad.Value) NodeHash

func (NodeHash) SQLValue added in v0.7.0

func (h NodeHash) SQLValue() interface{}

func (*NodeHash) Scan added in v0.6.0

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

type NullTime added in v0.6.1

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 added in v0.6.1

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

Scan implements the Scanner interface.

func (NullTime) Value added in v0.6.1

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

Value implements the driver Valuer interface.

type Optimizer added in v0.7.0

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

func NewOptimizer added in v0.7.0

func NewOptimizer() *Optimizer

func (*Optimizer) NoOffsetWithoutLimit added in v0.7.0

func (opt *Optimizer) NoOffsetWithoutLimit()

func (*Optimizer) OptimizeShape added in v0.7.0

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

func (*Optimizer) SetRegexpOp added in v0.7.1

func (opt *Optimizer) SetRegexpOp(op CmpOp)

type Placeholder added in v0.7.0

type Placeholder struct{}

func (Placeholder) SQL added in v0.7.0

func (Placeholder) SQL(b *Builder) string

type QuadHashes added in v0.6.0

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 added in v0.7.0

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 added in v0.7.0

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 added in v0.7.0

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 added in v0.7.0

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

type Registration added in v0.7.0

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 added in v0.7.0

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 added in v0.7.0

func AllNodes() Select

func AllQuads added in v0.7.0

func AllQuads(alias string) Select

func Nodes added in v0.7.0

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

func SelectValue added in v0.7.0

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

func (*Select) AppendParam added in v0.7.0

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

func (Select) Args added in v0.7.0

func (s Select) Args() []Value

func (Select) BuildIterator added in v0.7.0

func (s Select) BuildIterator(qs graph.QuadStore) graph.Iterator

func (Select) Clone added in v0.7.0

func (s Select) Clone() Select

func (Select) Columns added in v0.7.0

func (s Select) Columns() []string

func (Select) Optimize added in v0.7.0

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

func (Select) SQL added in v0.7.0

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

func (*Select) WhereEq added in v0.7.0

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

type Shape added in v0.7.0

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

type Source added in v0.7.0

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

type StringVal added in v0.7.0

type StringVal string

func (StringVal) SQLValue added in v0.7.0

func (v StringVal) SQLValue() interface{}

type Subquery added in v0.7.0

type Subquery struct {
	Query Select
	Alias string
}

func (Subquery) Args added in v0.7.0

func (s Subquery) Args() []Value

func (Subquery) SQL added in v0.7.0

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

type Table added in v0.7.0

type Table struct {
	Name  string
	Alias string
}

func (Table) Args added in v0.7.0

func (f Table) Args() []Value

func (Table) NameSQL added in v0.7.0

func (f Table) NameSQL() string

func (Table) SQL added in v0.7.0

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

type TimeVal added in v0.7.0

type TimeVal time.Time

func (TimeVal) SQLValue added in v0.7.0

func (v TimeVal) SQLValue() interface{}

type Value added in v0.7.0

type Value interface {
	SQLValue() interface{}
}

type ValueType added in v0.7.0

type ValueType int

func NodeValues added in v0.7.0

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

func (ValueType) Columns added in v0.7.0

func (t ValueType) Columns() []string

type Where added in v0.7.0

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

func (Where) SQL added in v0.7.0

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