action

package
v0.0.0-...-1c2aa41 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2017 License: MIT Imports: 9 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInTargetExpression

func IsInTargetExpression(targetExpression, schema, table *string) bool

func SetUpsertMethod

func SetUpsertMethod(upserter Upserter)

Types

type Action

type Action interface {
	// Execute the given action
	Execute(c *Context) error
	// Returns whether current action should be executed
	// for a targetExpression
	Filter(targetExpression string) bool
	// Returns whether the action needs to be batched separately to ensure
	// consistency. Some actions cannot run inside transactions, thus must have
	// a separate batch to ensure apply order and consistency.
	NeedsSeparatedBatch() bool
}

type AlterAttribute

type AlterAttribute struct {
	SchemaName string
	TypeName   string
	Column     Column
	NewColumn  Column
}

func (*AlterAttribute) Execute

func (a *AlterAttribute) Execute(c *Context) error

func (*AlterAttribute) Filter

func (a *AlterAttribute) Filter(targetExpression string) bool

func (*AlterAttribute) NeedsSeparatedBatch

func (a *AlterAttribute) NeedsSeparatedBatch() bool

type AlterColumn

type AlterColumn struct {
	SchemaName string
	TableName  string
	Column     Column
	NewColumn  Column
}

func (*AlterColumn) Execute

func (a *AlterColumn) Execute(c *Context) error

func (*AlterColumn) Filter

func (a *AlterColumn) Filter(targetExpression string) bool

func (*AlterColumn) NeedsSeparatedBatch

func (a *AlterColumn) NeedsSeparatedBatch() bool

type AlterFunction

type AlterFunction struct {
	SchemaName string
	Arguments  string
	SourceName string
	TargetName string
}

func (*AlterFunction) Execute

func (a *AlterFunction) Execute(c *Context) error

func (*AlterFunction) Filter

func (a *AlterFunction) Filter(targetExpression string) bool

func (*AlterFunction) NeedsSeparatedBatch

func (a *AlterFunction) NeedsSeparatedBatch() bool

type AlterIndex

type AlterIndex struct {
	SchemaName string
	SourceName string
	TargetName string
}

func (*AlterIndex) Execute

func (a *AlterIndex) Execute(c *Context) error

func (*AlterIndex) Filter

func (a *AlterIndex) Filter(targetExpression string) bool

func (*AlterIndex) NeedsSeparatedBatch

func (a *AlterIndex) NeedsSeparatedBatch() bool

type AlterSchema

type AlterSchema struct {
	SourceName string
	TargetName string
}

func (*AlterSchema) Execute

func (a *AlterSchema) Execute(c *Context) error

func (*AlterSchema) Filter

func (a *AlterSchema) Filter(targetExpression string) bool

func (*AlterSchema) NeedsSeparatedBatch

func (a *AlterSchema) NeedsSeparatedBatch() bool

type AlterTable

type AlterTable struct {
	SchemaName string
	SourceName string
	TargetName string
}

func (*AlterTable) Execute

func (a *AlterTable) Execute(c *Context) error

func (*AlterTable) Filter

func (a *AlterTable) Filter(targetExpression string) bool

func (*AlterTable) NeedsSeparatedBatch

func (a *AlterTable) NeedsSeparatedBatch() bool

type AlterType

type AlterType struct {
	SchemaName string
	SourceName string
	TargetName string
}

func (*AlterType) Execute

func (a *AlterType) Execute(c *Context) error

func (*AlterType) Filter

func (a *AlterType) Filter(targetExpression string) bool

func (*AlterType) NeedsSeparatedBatch

func (a *AlterType) NeedsSeparatedBatch() bool

type Column

type Column struct {
	Name         string
	Type         string
	IsNativeType bool
}

func (*Column) GetTypeSchemaStr

func (c *Column) GetTypeSchemaStr(schema string) string

type Context

type Context struct {
	Tx *sqlx.Tx
	Db *sqlx.DB
	// contains filtered or unexported fields
}

Defines the execution context of actions

func NewContext

func NewContext(tx *sqlx.Tx, db *sqlx.DB) *Context

func (*Context) Commit

func (c *Context) Commit() error

func (*Context) FlushStatements

func (c *Context) FlushStatements() error

func (*Context) GetPreparedStatement

func (c *Context) GetPreparedStatement(statement string) (*sqlx.Stmt, error)

type CreateAttribute

type CreateAttribute struct {
	SchemaName string
	TypeName   string
	Column     Column
}

func (*CreateAttribute) Execute

func (a *CreateAttribute) Execute(c *Context) error

func (*CreateAttribute) Filter

func (a *CreateAttribute) Filter(targetExpression string) bool

func (*CreateAttribute) NeedsSeparatedBatch

func (a *CreateAttribute) NeedsSeparatedBatch() bool

type CreateColumn

type CreateColumn struct {
	SchemaName string
	TableName  string
	Column     Column
}

func (*CreateColumn) Execute

func (a *CreateColumn) Execute(c *Context) error

func (*CreateColumn) Filter

func (a *CreateColumn) Filter(targetExpression string) bool

func (*CreateColumn) NeedsSeparatedBatch

func (a *CreateColumn) NeedsSeparatedBatch() bool

type CreateEnum

type CreateEnum struct {
	SchemaName string
	TypeName   string
	Name       string
}

func (*CreateEnum) Execute

func (a *CreateEnum) Execute(c *Context) error

func (*CreateEnum) Filter

func (a *CreateEnum) Filter(targetExpression string) bool

func (*CreateEnum) NeedsSeparatedBatch

func (a *CreateEnum) NeedsSeparatedBatch() bool

type CreateExtension

type CreateExtension struct {
	SchemaName    string
	ExtensionName string
}

func (*CreateExtension) Execute

func (a *CreateExtension) Execute(c *Context) error

func (*CreateExtension) Filter

func (a *CreateExtension) Filter(targetExpression string) bool

func (*CreateExtension) NeedsSeparatedBatch

func (a *CreateExtension) NeedsSeparatedBatch() bool

type CreateFunction

type CreateFunction struct {
	SchemaName   string
	FunctionName string
	FunctionDef  string
}

func (*CreateFunction) Execute

func (a *CreateFunction) Execute(c *Context) error

func (*CreateFunction) Filter

func (a *CreateFunction) Filter(targetExpression string) bool

func (*CreateFunction) NeedsSeparatedBatch

func (a *CreateFunction) NeedsSeparatedBatch() bool

type CreateIndex

type CreateIndex struct {
	SchemaName string
	IndexName  string
	IndexDef   string
}

func (*CreateIndex) Execute

func (a *CreateIndex) Execute(c *Context) error

func (*CreateIndex) Filter

func (a *CreateIndex) Filter(targetExpression string) bool

func (*CreateIndex) NeedsSeparatedBatch

func (a *CreateIndex) NeedsSeparatedBatch() bool

type CreateSchema

type CreateSchema struct {
	SchemaName string
}

func (*CreateSchema) Execute

func (a *CreateSchema) Execute(c *Context) error

func (*CreateSchema) Filter

func (a *CreateSchema) Filter(targetExpression string) bool

func (*CreateSchema) NeedsSeparatedBatch

func (a *CreateSchema) NeedsSeparatedBatch() bool

type CreateTable

type CreateTable struct {
	SchemaName string
	TableName  string
	PrimaryKey Column
}

func (*CreateTable) Execute

func (a *CreateTable) Execute(c *Context) error

func (*CreateTable) Filter

func (a *CreateTable) Filter(targetExpression string) bool

func (*CreateTable) NeedsSeparatedBatch

func (a *CreateTable) NeedsSeparatedBatch() bool

type CreateTrigger

type CreateTrigger struct {
	SchemaName  string
	TableName   string
	TriggerName string
	// BEFORE | AFTER | INSTEAD OF
	ExecutionOrder string
	// INSERT | UPDATE | DELETE
	Events        []string
	ProcedureName string
}

func (*CreateTrigger) Execute

func (a *CreateTrigger) Execute(c *Context) error

func (*CreateTrigger) Filter

func (a *CreateTrigger) Filter(targetExpression string) bool

func (*CreateTrigger) NeedsSeparatedBatch

func (a *CreateTrigger) NeedsSeparatedBatch() bool

type CreateType

type CreateType struct {
	SchemaName string
	TypeName   string
	TypeType   string
}

func (*CreateType) Execute

func (a *CreateType) Execute(c *Context) error

func (*CreateType) Filter

func (a *CreateType) Filter(targetExpression string) bool

func (*CreateType) NeedsSeparatedBatch

func (a *CreateType) NeedsSeparatedBatch() bool

type DeleteRow

type DeleteRow struct {
	SchemaName string
	TableName  string
	PrimaryKey Row
}

func (*DeleteRow) Execute

func (a *DeleteRow) Execute(c *Context) error

func (*DeleteRow) Filter

func (a *DeleteRow) Filter(targetExpression string) bool

func (*DeleteRow) NeedsSeparatedBatch

func (a *DeleteRow) NeedsSeparatedBatch() bool

type DropAttribute

type DropAttribute struct {
	SchemaName string
	TypeName   string
	Column     Column
}

func (*DropAttribute) Execute

func (a *DropAttribute) Execute(c *Context) error

func (*DropAttribute) Filter

func (a *DropAttribute) Filter(targetExpression string) bool

func (*DropAttribute) NeedsSeparatedBatch

func (a *DropAttribute) NeedsSeparatedBatch() bool

type DropColumn

type DropColumn struct {
	SchemaName string
	TableName  string
	Column     Column
}

func (*DropColumn) Execute

func (a *DropColumn) Execute(c *Context) error

func (*DropColumn) Filter

func (a *DropColumn) Filter(targetExpression string) bool

func (*DropColumn) NeedsSeparatedBatch

func (a *DropColumn) NeedsSeparatedBatch() bool

type DropExtension

type DropExtension struct {
	ExtensionName string
}

func (*DropExtension) Execute

func (a *DropExtension) Execute(c *Context) error

func (*DropExtension) Filter

func (a *DropExtension) Filter(targetExpression string) bool

func (*DropExtension) NeedsSeparatedBatch

func (a *DropExtension) NeedsSeparatedBatch() bool

type DropFunction

type DropFunction struct {
	SchemaName   string
	FunctionName string
	Arguments    string
}

func (*DropFunction) Execute

func (a *DropFunction) Execute(c *Context) error

func (*DropFunction) Filter

func (a *DropFunction) Filter(targetExpression string) bool

func (*DropFunction) NeedsSeparatedBatch

func (a *DropFunction) NeedsSeparatedBatch() bool

type DropIndex

type DropIndex struct {
	SchemaName string
	IndexName  string
}

func (*DropIndex) Execute

func (a *DropIndex) Execute(c *Context) error

func (*DropIndex) Filter

func (a *DropIndex) Filter(targetExpression string) bool

func (*DropIndex) NeedsSeparatedBatch

func (a *DropIndex) NeedsSeparatedBatch() bool

type DropSchema

type DropSchema struct {
	SchemaName string
}

func (*DropSchema) Execute

func (a *DropSchema) Execute(c *Context) error

func (*DropSchema) Filter

func (a *DropSchema) Filter(targetExpression string) bool

func (*DropSchema) NeedsSeparatedBatch

func (a *DropSchema) NeedsSeparatedBatch() bool

type DropTable

type DropTable struct {
	SchemaName string
	TableName  string
}

func (*DropTable) Execute

func (a *DropTable) Execute(c *Context) error

func (*DropTable) Filter

func (a *DropTable) Filter(targetExpression string) bool

func (*DropTable) NeedsSeparatedBatch

func (a *DropTable) NeedsSeparatedBatch() bool

type DropTrigger

type DropTrigger struct {
	SchemaName  string
	TableName   string
	TriggerName string
}

func (*DropTrigger) Execute

func (a *DropTrigger) Execute(c *Context) error

func (*DropTrigger) Filter

func (a *DropTrigger) Filter(targetExpression string) bool

func (*DropTrigger) NeedsSeparatedBatch

func (a *DropTrigger) NeedsSeparatedBatch() bool

type DropType

type DropType struct {
	SchemaName string
	TypeName   string
}

func (*DropType) Execute

func (a *DropType) Execute(c *Context) error

func (*DropType) Filter

func (a *DropType) Filter(targetExpression string) bool

func (*DropType) NeedsSeparatedBatch

func (a *DropType) NeedsSeparatedBatch() bool

type FallbackUpserter

type FallbackUpserter struct{}

type InsertRow

type InsertRow struct {
	SchemaName     string
	TableName      string
	PrimaryKeyName string
	Rows           Rows
	BulkInsert     bool
}

func (*InsertRow) Execute

func (a *InsertRow) Execute(c *Context) error

func (*InsertRow) Filter

func (a *InsertRow) Filter(targetExpression string) bool

func (*InsertRow) NeedsSeparatedBatch

func (a *InsertRow) NeedsSeparatedBatch() bool

type OnConflictUpserter

type OnConflictUpserter struct{}

type Row

type Row struct {
	Value  interface{}
	Column Column
}

func (*Row) GetValue

func (r *Row) GetValue() interface{}

type RowData

type RowData struct {
	EscapedCols   []string
	EscapedRows   []string
	Values        []interface{}
	PrimaryKeyRow Row
	SchemaName    string
	TableName     string
	Rows          Rows
}

func (RowData) InsertOnConstraintUpdateQuery

func (r RowData) InsertOnConstraintUpdateQuery() string

func (RowData) InsertValuesQuery

func (r RowData) InsertValuesQuery() string

func (RowData) ReleaseSavePointQuery

func (r RowData) ReleaseSavePointQuery() string

func (RowData) RollbackSavePointQuery

func (r RowData) RollbackSavePointQuery() string

func (RowData) SavePointQuery

func (r RowData) SavePointQuery() string

type Rows

type Rows []Row

func (Rows) Len

func (slice Rows) Len() int

Implement Interface

func (Rows) Less

func (slice Rows) Less(i, j int) bool

func (Rows) Swap

func (slice Rows) Swap(i, j int)

type UpdateRow

type UpdateRow struct {
	SchemaName string
	TableName  string
	PrimaryKey Row
	Rows       []Row
}

func (*UpdateRow) Execute

func (a *UpdateRow) Execute(c *Context) error

func (*UpdateRow) Filter

func (a *UpdateRow) Filter(targetExpression string) bool

func (*UpdateRow) NeedsSeparatedBatch

func (a *UpdateRow) NeedsSeparatedBatch() bool

type Upserter

type Upserter interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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