sql

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LessThanComparisonSign            ValueComparisonSign = "<"
	LessThanOrEqualsComparisonSign                        = "<="
	EqualsComparisonSign                                  = "="
	GreaterThanOrEqualsComparisonSign                     = ">="
	GreaterThanComparisonSign                             = ">"
	NotEqualsComparisonSign                               = "!="
)

Variables

This section is empty.

Functions

func BuildDMLDeleteQuery

func BuildDMLDeleteQuery(databaseName, tableName string, tableColumns, uniqueKeyColumns *ColumnList, args []interface{}) (result string, uniqueKeyArgs []interface{}, err error)

func BuildDMLInsertQuery

func BuildDMLInsertQuery(databaseName, tableName string, tableColumns, sharedColumns *ColumnList, args []interface{}) (result string, sharedArgs []interface{}, err error)

func BuildDMLUpdateQuery

func BuildDMLUpdateQuery(databaseName, tableName string, tableColumns, sharedColumns, uniqueKeyColumns *ColumnList, valueArgs, whereArgs []interface{}) (result string, sharedArgs, uniqueKeyArgs []interface{}, err error)

func BuildEqualsComparison

func BuildEqualsComparison(columns []string, values []string) (result string, err error)

func BuildEqualsPreparedComparison

func BuildEqualsPreparedComparison(columns []string) (result string, err error)

func BuildRangeComparison

func BuildRangeComparison(columns []string, values []string, args []interface{}, comparisonSign ValueComparisonSign) (result string, explodedArgs []interface{}, err error)

func BuildRangeInsertPreparedQuery

func BuildRangeInsertPreparedQuery(databaseName, originalTableName, ghostTableName string, sharedColumns []string, mappedSharedColumns []string, uniqueKey string, uniqueKeyColumns []string, rangeStartArgs, rangeEndArgs []interface{}, includeRangeStartValues bool, transactionalTable bool) (result string, explodedArgs []interface{}, err error)

func BuildRangeInsertQuery

func BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName string, sharedColumns []string, mappedSharedColumns []string, uniqueKey string, uniqueKeyColumns, rangeStartValues, rangeEndValues []string, rangeStartArgs, rangeEndArgs []interface{}, includeRangeStartValues bool, transactionalTable bool) (result string, explodedArgs []interface{}, err error)

func BuildRangePreparedComparison

func BuildRangePreparedComparison(columns []string, args []interface{}, comparisonSign ValueComparisonSign) (result string, explodedArgs []interface{}, err error)

func BuildSetPreparedClause

func BuildSetPreparedClause(columns []string) (result string, err error)

func BuildUniqueKeyMaxValuesPreparedQuery

func BuildUniqueKeyMaxValuesPreparedQuery(databaseName, tableName string, uniqueKeyColumns []string) (string, error)

func BuildUniqueKeyMinValuesPreparedQuery

func BuildUniqueKeyMinValuesPreparedQuery(databaseName, tableName string, uniqueKeyColumns []string) (string, error)

func BuildUniqueKeyRangeEndPreparedQuery

func BuildUniqueKeyRangeEndPreparedQuery(databaseName, tableName string, uniqueKeyColumns []string, rangeStartArgs, rangeEndArgs []interface{}, chunkSize int64, includeRangeStartValues bool, hint string) (result string, explodedArgs []interface{}, err error)

func BuildValueComparison

func BuildValueComparison(column string, value string, comparisonSign ValueComparisonSign) (result string, err error)

func EscapeName

func EscapeName(name string) string

EscapeName will escape a db/table/column/... name by wrapping with backticks. It is not fool proof. I'm just trying to do the right thing here, not solving SQL injection issues, which should be irrelevant for this tool.

Types

type ColumnList

type ColumnList struct {
	Names    []string
	Ordinals ColumnsMap
}

ColumnList makes for a named list of columns

func NewColumnList

func NewColumnList(names []string) *ColumnList

NewColumnList creates an object given ordered list of column names

func ParseColumnList

func ParseColumnList(columns string) *ColumnList

ParseColumnList parses a comma delimited list of column names

func (*ColumnList) Equals

func (this *ColumnList) Equals(other *ColumnList) bool

func (*ColumnList) IsSubsetOf

func (this *ColumnList) IsSubsetOf(other *ColumnList) bool

IsSubsetOf returns 'true' when column names of this list are a subset of another list, in arbitrary order (order agnostic)

func (*ColumnList) Len

func (this *ColumnList) Len() int

func (*ColumnList) String

func (this *ColumnList) String() string

type ColumnValues

type ColumnValues struct {
	ValuesPointers []interface{}
	// contains filtered or unexported fields
}

func NewColumnValues

func NewColumnValues(length int) *ColumnValues

func ToColumnValues

func ToColumnValues(abstractValues []interface{}) *ColumnValues

func (*ColumnValues) AbstractValues

func (this *ColumnValues) AbstractValues() []interface{}

func (*ColumnValues) String

func (this *ColumnValues) String() string

func (*ColumnValues) StringColumn

func (this *ColumnValues) StringColumn(index int) string

type ColumnsMap

type ColumnsMap map[string]int

ColumnsMap maps a column onto its ordinal position

func NewColumnsMap

func NewColumnsMap(orderedNames []string) ColumnsMap

type Parser added in v0.9.6

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

func NewParser added in v0.9.6

func NewParser() *Parser

func (*Parser) GetNonTrivialRenames added in v0.9.6

func (this *Parser) GetNonTrivialRenames() map[string]string

func (*Parser) HasNonTrivialRenames added in v0.9.6

func (this *Parser) HasNonTrivialRenames() bool

func (*Parser) ParseAlterStatement added in v0.9.6

func (this *Parser) ParseAlterStatement(alterStatement string) (err error)

type UniqueKey

type UniqueKey struct {
	Name            string
	Columns         ColumnList
	HasNullable     bool
	IsAutoIncrement bool
}

UniqueKey is the combination of a key's name and columns

func (*UniqueKey) IsPrimary

func (this *UniqueKey) IsPrimary() bool

IsPrimary checks if this unique key is primary

func (*UniqueKey) Len

func (this *UniqueKey) Len() int

func (*UniqueKey) String

func (this *UniqueKey) String() string

type ValueComparisonSign

type ValueComparisonSign string

Jump to

Keyboard shortcuts

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