info

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	//Region defines catalog region (only for cloud database)
	Region = "Region"
	//Catalog defines catalog kind literal
	Catalog = "Catalog"
	//Schema defines schema kind literal
	Schema = "Schema"
	//Table defines table kind literal
	Table = "Table"
	//Index defines index kind literal
	Index = "Restriction"
	//View defines view kind literal
	View = "View"
	//Sequence defines sequence kind literal
	Sequence = "Sequence"
	//Function defines function kind literal
	Function = "Function"
	// SequenceNewCurrentValue defines kind literal
	SequenceNewCurrentValue = "SequenceNewCurrentValue"
	// Object defines kind literal
	Object = "Object"
)
View Source
const (
	//KindVersion defines information kind
	KindVersion = Kind(iota)
	//KindCatalogs defines catalogs kind
	KindCatalogs
	//KindCatalog defines catalog kind
	KindCatalog
	//KindCurrentSchema defines current schema kind
	KindCurrentSchema
	//KindSchemas defines schemas kind
	KindSchemas
	//KindSchema defines schema kind
	KindSchema
	//KindTables defines tabkes kind
	KindTables
	//KindTable defines table kind
	KindTable
	//KindViews defines views kind
	KindViews
	//KindView defines view kind
	KindView
	//KindPrimaryKeys defines primary keys kind
	KindPrimaryKeys
	//KindForeignKeys defines foreign key kind
	KindForeignKeys
	//KindConstraints defines constraints kind
	KindConstraints
	//KindIndexes defines indexes kind
	KindIndexes
	//KindIndex defines index kind
	KindIndex
	//KindSequences defines sequences kind
	KindSequences
	//KindFunctions defines functions kind
	KindFunctions
	//KindSession defines session kind
	KindSession
	//KindForeignKeysCheckOn defines fk check on kind
	KindForeignKeysCheckOn
	//KindForeignKeysCheckOff defines fk check off kind
	KindForeignKeysCheckOff
	// KindSequenceNextValue defines setting next value of sequence/autoincrement/identity kind
	KindSequenceNextValue
	// KindLockGet defines lock get kind
	KindLockGet
	// KindLockRelease defines lock release kind
	KindLockRelease
	//KindReserved defines reserved kind
	KindReserved
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Criteria

type Criteria []*Criterion

Criteria represents Criterion collection

func (Criteria) Supported

func (c Criteria) Supported() int

Supported returns true if supported

func (Criteria) Validate

func (c Criteria) Validate(kind Kind) error

Validate validates criteria kind

type Criterion

type Criterion struct {
	Name   string
	Column string
}

Criterion represents query criterion

func NewCriterion

func NewCriterion(name, column string) *Criterion

NewCriterion creates a new criteria, name refers to kind.Crtiera, column to local vendor column, use '?' for already defined placeholder, %v for substitution

type DefaultHandler

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

DefaultHandler represents default handler, implements Handler interface

func NewHandler

func NewHandler(fn func(ctx context.Context, db *sql.DB, target interface{}, options ...interface{}) (doNext bool, err error)) *DefaultHandler

NewHandler creates new DefaultHandler

func (*DefaultHandler) CanUse

func (h *DefaultHandler) CanUse(options ...interface{}) bool

CanUse default implementation Handler's CanUse function

func (*DefaultHandler) Handle

func (h *DefaultHandler) Handle(ctx context.Context, db *sql.DB, target interface{}, options ...interface{}) (doNext bool, err error)

Handle default implementation Handler's Handle function

type Dialect

type Dialect struct {
	database.Product
	Placeholder         string // prepare statement placeholder, default '?', but oracle uses ':'
	PlaceholderResolver placeholder.Generator
	Transactional       bool
	Insert              dialect.InsertFeatures
	Upsert              dialect.UpsertFeatures
	Load                dialect.LoadFeature
	//LoadResolver        temp.SessionResolver
	CanAutoincrement  bool
	AutoincrementFunc string
	CanLastInsertID   bool
	CanReturning      bool //Postgress supports Returning Data From Modified Rows in one statement
	QuoteCharacter    byte
	// TODO: check if column has a space or exist in keywords in this case use quote if keyword is specified
	// i.e. normalized column on the dialect
	Keywords                map[string]bool
	DefaultPresetIDStrategy dialect.PresetIDStrategy
}

Dialect represents dialect

func (*Dialect) EnsurePlaceholders

func (d *Dialect) EnsurePlaceholders(SQL string) string

EnsurePlaceholders converts '?' to specific dialect placeholders if needed

func (*Dialect) PlaceholderGetter

func (d *Dialect) PlaceholderGetter() func() string

PlaceholderGetter returns PlaceholderResolver if not nil, otherwise returns function that returns Placeholder

type Dialects

type Dialects []*Dialect

Dialects represents dialects

func (Dialects) Len

func (a Dialects) Len() int

func (Dialects) Less

func (a Dialects) Less(i, j int) bool

func (Dialects) Swap

func (a Dialects) Swap(i, j int)

type Handler

type Handler interface {
	Handle(ctx context.Context, db *sql.DB, target interface{}, options ...interface{}) (doNext bool, err error)
	CanUse(options ...interface{}) bool
}

Handler interface for handling pre- and post-query custom functions

func NopHandler added in v0.3.0

func NopHandler() Handler

NopHandler returns nop handler

type Kind

type Kind int

Kind represents dictionary info kind

func (Kind) Criteria

func (k Kind) Criteria() []string

Criteria defines criteria for each query kind

func (Kind) String

func (k Kind) String() string

type Queries

type Queries []*Query

Queries represents querties

func (Queries) Len

func (q Queries) Len() int

func (Queries) Less

func (q Queries) Less(i, j int) bool

Less is part of sort.Interface.

func (Queries) Match

func (q Queries) Match(info *database.Product) *Query

Match matches queries for version, or latest version

func (Queries) Swap

func (q Queries) Swap(i, j int)

Swap is part of sort.Interface.

type Query

type Query struct {
	Kind     Kind
	SQL      string
	Criteria Criteria
	database.Product
	PreHandlers  []Handler
	PostHandlers []Handler
}

Query represents dictionary query

func NewQuery

func NewQuery(kind Kind, SQL string, info database.Product, criteria ...*Criterion) *Query

NewQuery creates a new query

func (*Query) OnPost

func (q *Query) OnPost(auxiliaries ...Handler) *Query

OnPost sets Query's PostHandlers

func (*Query) OnPre

func (q *Query) OnPre(auxiliaries ...Handler) *Query

OnPre sets Query's PreHandlers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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