db

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: BSD-2-Clause Imports: 17 Imported by: 6

Documentation

Index

Constants

View Source
const (
	OFFSET_PARAM = "OFFSET_PARAM"
	LIMIT_PARAM  = "LIMIT_PARAM"
)
View Source
const FK_NAV_SEP = "."
View Source
const JOIN_PREFIX = "j"
View Source
const PARAMETER_SEPARATORS = `"':&,;()|=+-*%/\<>^`

Set of characters that qualify as parameter separators, indicating that a parameter name in a SQL String has ended.

View Source
const PREFIX = "t"

Variables

View Source
var (
	OPTIMISTIC_LOCK_MSG = "No update was possible for this version of the data. Data may have changed."
	VERSION_SET_MSG     = "Unable to set Version data."
)
View Source
var START_SKIP = []string{"'", "\"", "--", "/*"}

Set of characters that qualify as comment or quotes starting characters.

View Source
var STOP_SKIP = []string{"'", "\"", "\n", "*/"}

Set of characters that at are the corresponding comment or quotes ending characters.

View Source
var TOKEN_ADD = "ADD"
View Source
var TOKEN_ALIAS = "ALIAS"
View Source
var TOKEN_AND = "AND"
View Source
var TOKEN_ASIS = "VAL" // value is injected to the SQL as is.
View Source
var TOKEN_BOUNDEDRANGE = "BOUNDEDRANGE"
View Source
var TOKEN_CASE = "CASE"
View Source
var TOKEN_CASE_ELSE = "CASE_ELSE"
View Source
var TOKEN_CASE_WHEN = "CASE_WHEN"
View Source
var TOKEN_COALESCE = "COALESCE"
View Source
var TOKEN_COLUMN = "COLUMN"
View Source
var TOKEN_COUNT = "COUNT" // COUNT(*)
View Source
var TOKEN_COUNT_COLUMN = "COUNT_COLUMN" // COUNT(COLUMN)
View Source
var TOKEN_DIVIDE = "DIVIDE"
View Source
var TOKEN_EQ = "EQ"

CONDITIONS

View Source
var TOKEN_EXISTS = "EXISTS"
View Source
var TOKEN_GT = "GT"
View Source
var TOKEN_GTEQ = "GTEQ"
View Source
var TOKEN_IEQ = "IEQ"
View Source
var TOKEN_IGT = "IGT"
View Source
var TOKEN_IGTEQ = "IGTEQ"
View Source
var TOKEN_ILIKE = "ILIKE"
View Source
var TOKEN_ILT = "ILT"
View Source
var TOKEN_ILTEQ = "ILTEQ"
View Source
var TOKEN_IN = "IN"
View Source
var TOKEN_ISNULL = "ISNULL"
View Source
var TOKEN_LIKE = "LIKE"
View Source
var TOKEN_LOWER = "LOWER"
View Source
var TOKEN_LT = "LT"
View Source
var TOKEN_LTEQ = "LTEQ"
View Source
var TOKEN_MAX = "MAX"
View Source
var TOKEN_MIN = "MIN"
View Source
var TOKEN_MINUS = "MINUS"
View Source
var TOKEN_MULTIPLY = "MULTIPLY"
View Source
var TOKEN_NEQ = "NEQ"
View Source
var TOKEN_NOT = "NOT"
View Source
var TOKEN_NULL = "NULL" // sets a predefined value
View Source
var TOKEN_OR = "OR"
View Source
var TOKEN_PARAM = "PARAM" // parameter

FUNCTIONS

View Source
var TOKEN_RANGE = "RANGE"
View Source
var TOKEN_RAW = "RAW" // sets a predefined value
View Source
var TOKEN_RTRIM = "RTRIM"
View Source
var TOKEN_SUBQUERY = "SUBQUERY"
View Source
var TOKEN_SUM = "SUM"
View Source
var TOKEN_UPPER = "UPPER"
View Source
var TOKEN_VALUERANGE = "VALUERANGE"

entity mapping

Functions

func AddEntity

func AddEntity(table *Table)

func SubstituteNamedParameters

func SubstituteNamedParameters(parsedSql *ParsedSql, translator Translator) string

Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a '?' placeholder

param parsedSql

the parsed represenation of the SQL statement

param paramSource

the source for named parameters

return the SQL statement with substituted parameters see #parseSqlStatement

func TmWithDbFactory added in v1.5.0

func TmWithDbFactory(dbFactory func(dbx.IConnection, Mapper) IDb) func(*TransactionManager)

Types

type AliasBag

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

This struct gives the SAME alias when traversing the JOINS

Note: two lists of joins (a path), they have diferent FK alias from the moment they differ

func NewAliasBag

func NewAliasBag(prefix string) *AliasBag

func (*AliasBag) GetAlias

func (a *AliasBag) GetAlias(fk *Association) string

func (*AliasBag) Has

func (a *AliasBag) Has(fk *Association) bool

func (*AliasBag) SetAlias

func (a *AliasBag) SetAlias(fk *Association, alias string)

type Association

type Association struct {
	FromM2M *Association
	ToM2M   *Association

	Alias string
	// contains filtered or unexported fields
}

func NewAssociation

func NewAssociation(relations ...Relation) *Association

func NewAssociationAs

func NewAssociationAs(name string, relations ...Relation) *Association

func NewAssociationCopy

func NewAssociationCopy(fk *Association) *Association

func NewM2MAssociation

func NewM2MAssociation(alias string, fkFrom *Association, fkTo *Association) *Association

Creates a many to many association by using the relations defined in each association

func (*Association) As

func (a *Association) As(alias string) *Association

func (*Association) Clone

func (a *Association) Clone() interface{}

func (*Association) Equals

func (a *Association) Equals(o interface{}) bool

func (*Association) GenericPath

func (a *Association) GenericPath() string

func (*Association) GetAliasFrom

func (a *Association) GetAliasFrom() string

func (*Association) GetAliasTo

func (a *Association) GetAliasTo() string

func (*Association) GetDiscriminatorTable

func (a *Association) GetDiscriminatorTable() *Table

func (*Association) GetDiscriminators

func (a *Association) GetDiscriminators() []Discriminator

func (*Association) GetRelations

func (a *Association) GetRelations() []Relation

func (*Association) GetTableFrom

func (a *Association) GetTableFrom() *Table

func (*Association) GetTableMany2Many

func (a *Association) GetTableMany2Many() *Table

func (*Association) GetTableTo

func (a *Association) GetTableTo() *Table

func (*Association) HashCode

func (a *Association) HashCode() int

func (*Association) IsMany2Many

func (a *Association) IsMany2Many() bool

func (*Association) Path

func (a *Association) Path() string

func (*Association) SetAliasFrom

func (a *Association) SetAliasFrom(aliasFrom string)

func (*Association) SetAliasTo

func (a *Association) SetAliasTo(aliasTo string)

func (*Association) SetDiscriminators

func (a *Association) SetDiscriminators(discriminators ...Discriminator)

func (*Association) String

func (a *Association) String() string

func (*Association) With

func (a *Association) With(column *Column, value interface{}) *Association

type AutoKeyStrategy

type AutoKeyStrategy int
const (
	AUTOKEY_NONE AutoKeyStrategy = iota
	AUTOKEY_BEFORE
	AUTOKEY_RETURNING
	AUTOKEY_AFTER
)

type ColGroup

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

func ASSOCIATE

func ASSOCIATE(from ...*Column) ColGroup

func (ColGroup) TO

func (cg ColGroup) TO(to ...*Column) Relashionships

func (ColGroup) WITH

func (cg ColGroup) WITH(to ...*Column) *Association

type Column

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

func (*Column) As

func (c *Column) As(alias string) *Column

Param alias: The alias of the column return

func (*Column) Clone

func (c *Column) Clone() interface{}

func (*Column) Deletion

func (c *Column) Deletion() *Column

/**

  • set this as a deletion column *
  • @return */

func (*Column) Different

func (c *Column) Different(value interface{}) *Criteria

func (*Column) Equals

func (c *Column) Equals(o interface{}) bool

func (*Column) For

func (c *Column) For(tableAlias string) *ColumnHolder

Defines the table alias for this column in the SQL

func (*Column) GetAlias

func (c *Column) GetAlias() string

func (*Column) GetName

func (c *Column) GetName() string

/**

  • obtem o nome da coluna *
  • @return nome da coluna */

func (*Column) GetTable

func (c *Column) GetTable() *Table

Gets the table that this column belongs to

returns the table

func (*Column) Greater

func (c *Column) Greater(value interface{}) *Criteria

func (*Column) GreaterOrMatch

func (c *Column) GreaterOrMatch(value interface{}) *Criteria

func (*Column) HashCode

func (c *Column) HashCode() int

func (*Column) ILike

func (c *Column) ILike(right interface{}) *Criteria

func (*Column) IMatches

func (c *Column) IMatches(value interface{}) *Criteria

func (*Column) In

func (c *Column) In(value ...interface{}) *Criteria

func (*Column) IsDeletion

func (c *Column) IsDeletion() bool

func (*Column) IsKey

func (c *Column) IsKey() bool

/**

  • indica se é uma coluna chave *
  • @return se é coluna chave */

func (*Column) IsMandatory

func (c *Column) IsMandatory() bool

func (*Column) IsNull

func (c *Column) IsNull() *Criteria

func (*Column) IsVersion

func (c *Column) IsVersion() bool

func (*Column) Key

func (c *Column) Key() *Column

set this as a key column

return

func (*Column) Lesser

func (c *Column) Lesser(value interface{}) *Criteria

func (*Column) LesserOrMatch

func (c *Column) LesserOrMatch(value interface{}) *Criteria

func (*Column) Like

func (c *Column) Like(right interface{}) *Criteria

func (*Column) Mandatory

func (c *Column) Mandatory() *Column

set this as a mandatory column

return

func (*Column) Matches

func (c *Column) Matches(value interface{}) *Criteria

func (*Column) Range

func (c *Column) Range(left, right interface{}) *Criteria

func (*Column) String

func (c *Column) String() string

/**

  • devolve a representação em String desta coluna. *
  • @return devolve string com o formato 'table.coluna' */

func (*Column) Version

func (c *Column) Version() *Column

/**

  • set this as a version column *
  • @return */

type ColumnHolder

type ColumnHolder struct {
	Token
	// contains filtered or unexported fields
}

can hold a Column, a Token or any constante

func Col

func Col(column *Column) *ColumnHolder

func NewColumnHolder

func NewColumnHolder(column *Column) *ColumnHolder

func (*ColumnHolder) As

func (c *ColumnHolder) As(alias string) *ColumnHolder

func (*ColumnHolder) Clone

func (c *ColumnHolder) Clone() interface{}

func (*ColumnHolder) Equals

func (c *ColumnHolder) Equals(o interface{}) bool

func (*ColumnHolder) For

func (c *ColumnHolder) For(tableAlias string) *ColumnHolder

func (*ColumnHolder) GetAlias

func (c *ColumnHolder) GetAlias() string

func (*ColumnHolder) GetColumn

func (c *ColumnHolder) GetColumn() *Column

func (*ColumnHolder) HashCode

func (c *ColumnHolder) HashCode() int

func (*ColumnHolder) SetTableAlias

func (c *ColumnHolder) SetTableAlias(tableAlias string)

type Converter

type Converter interface {
	ToDb(in interface{}) (interface{}, error)
	FromDbInstance() interface{}
	FromDb(in interface{}) (interface{}, error)
}

Converter converts the data stored in the database into the data stored in the struct and vice-versa

type Crawler

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

The objective of this structure is to maintain state, while crawling the associations and building the entity tree, after an sql select This way it is possible to hint the row transformers wich paths to follow. While crawling the associations of a query result the list of possible paths changes.

The process has 2 steps:

  1. building a tree (common foreign keys are converted into one) to identify wich branches exist for a node
  2. building an array that only has the edge nodes of a tree (tree contour) to ease the computation of the column offsets of each processed entity

func (*Crawler) Dispose

func (c *Crawler) Dispose()

func (*Crawler) Forward

func (c *Crawler) Forward()

func (*Crawler) GetBranches

func (c *Crawler) GetBranches() []*CrawlerNode

func (*Crawler) Prepare

func (c *Crawler) Prepare(query *Query)

func (*Crawler) Rewind

func (c *Crawler) Rewind()

type CrawlerNode

type CrawlerNode struct {
	ForeignKey *Association
	// contains filtered or unexported fields
}

func (*CrawlerNode) BuildTree

func (c *CrawlerNode) BuildTree(fks []*Association, table *HoldTable)

To guarantee that the several joins are chained and assessed correctly a tree is built only for validation

func (*CrawlerNode) FlatenTree

func (c *CrawlerNode) FlatenTree(flat []*CrawlerNode) []*CrawlerNode

builds an array with all the tree nodes by entry order param: flat

func (*CrawlerNode) GetBranches

func (c *CrawlerNode) GetBranches() []*CrawlerNode

func (*CrawlerNode) String

func (c *CrawlerNode) String() string

type Criteria

type Criteria struct {
	*Token
	IsNot bool
	// contains filtered or unexported fields
}

* Criteria

func And

func And(operations ...*Criteria) *Criteria

func BoundedValueRange

func BoundedValueRange(bottom, top interface{}, value Tokener) *Criteria

func Different

func Different(left, right interface{}) *Criteria

func Exists

func Exists(token interface{}) *Criteria

func Greater

func Greater(left, right interface{}) *Criteria

func GreaterOrMatch

func GreaterOrMatch(left, right interface{}) *Criteria

func ILike

func ILike(left, right interface{}) *Criteria

func IMatches

func IMatches(left, right interface{}) *Criteria

func In

func In(column interface{}, values ...interface{}) *Criteria

func IsNull

func IsNull(token interface{}) *Criteria

func Lesser

func Lesser(left, right interface{}) *Criteria

func LesserOrMatch

func LesserOrMatch(left, right interface{}) *Criteria

func Like

func Like(left, right interface{}) *Criteria

func Matches

func Matches(left, right interface{}) *Criteria

func NewCriteria

func NewCriteria(operator string, members ...interface{}) *Criteria

func Not

func Not(token interface{}) *Criteria

func Or

func Or(operations ...*Criteria) *Criteria

func Range

func Range(receiver, bottom, top interface{}) *Criteria

func ValueRange

func ValueRange(bottom, top interface{}, value Tokener) *Criteria

func (*Criteria) And

func (c *Criteria) And(criteria *Criteria) *Criteria

func (*Criteria) Clone

func (c *Criteria) Clone() interface{}

func (*Criteria) GetLeft

func (c *Criteria) GetLeft() Tokener

func (*Criteria) GetRight

func (c *Criteria) GetRight() Tokener

func (*Criteria) Not

func (c *Criteria) Not() *Criteria

func (*Criteria) Or

func (c *Criteria) Or(criteria *Criteria) *Criteria

func (*Criteria) SetLeft

func (c *Criteria) SetLeft(left interface{})

func (*Criteria) SetRight

func (c *Criteria) SetRight(right interface{})

type Db

type Db struct {
	Connection dbx.IConnection
	Translator Translator
	// contains filtered or unexported fields
}

func NewDb

func NewDb(connection dbx.IConnection, translator Translator, cacher Mapper) *Db

func (*Db) Create

func (d *Db) Create(instance interface{}) error

func (*Db) Delete

func (d *Db) Delete(table *Table) *Delete

the idea is to centralize the query creation so that future customization could be made

func (*Db) FindAll

func (d *Db) FindAll(instance interface{}, example interface{}) error

func (*Db) FindFirst

func (d *Db) FindFirst(instance interface{}, example interface{}) (bool, error)

func (*Db) GetAttribute

func (d *Db) GetAttribute(key string) (interface{}, bool)

func (*Db) GetConnection

func (d *Db) GetConnection() dbx.IConnection

func (*Db) GetContext added in v1.5.0

func (d *Db) GetContext() context.Context

func (*Db) GetTranslator

func (d *Db) GetTranslator() Translator

func (*Db) Insert

func (d *Db) Insert(table *Table) *Insert

the idea is to centralize the query creation so that future customization could be made

func (*Db) Modify

func (d *Db) Modify(instance interface{}) (bool, error)

func (*Db) PopulateMapping added in v1.4.2

func (d *Db) PopulateMapping(prefix string, typ reflect.Type) (map[string]*EntityProperty, error)

func (*Db) Query

func (d *Db) Query(table *Table) *Query

the idea is to centralize the query creation so that future customization could be made

func (*Db) Remove

func (d *Db) Remove(instance interface{}) (bool, error)

func (*Db) RemoveAll

func (d *Db) RemoveAll(instance interface{}) (int64, error)

removes all that match the criteria defined by the non zero values by the struct.

func (*Db) Retrieve added in v1.3.0

func (d *Db) Retrieve(instance interface{}, keys ...interface{}) (bool, error)

func (*Db) Save

func (d *Db) Save(instance interface{}) (bool, error)

Inserts or Updates a record depending on the value of the Version.

If version is nil or zero, an insert is issue, otherwise an update. If there is no version column it returns an error.

func (*Db) SetAttribute

func (d *Db) SetAttribute(key string, value interface{})

func (*Db) Update

func (d *Db) Update(table *Table) *Update

the idea is to centralize the query creation so that future customization could be made

func (*Db) WithContext added in v1.5.0

func (d *Db) WithContext(ctx context.Context) IDb

type Delete

type Delete struct {
	DmlCore
}

func NewDelete

func NewDelete(db IDb, table *Table) *Delete

func (*Delete) Alias

func (d *Delete) Alias(alias string) *Delete

func (*Delete) Execute

func (d *Delete) Execute() (int64, error)

func (*Delete) Submit

func (d *Delete) Submit(value interface{}) (int64, error)

func (*Delete) Where

func (d *Delete) Where(restriction ...*Criteria) *Delete

type Discriminator

type Discriminator struct {
	Column *Column
	Value  Tokener
}

func NewDiscriminator

func NewDiscriminator(column *Column, value Tokener) Discriminator

func (Discriminator) Criteria

func (d Discriminator) Criteria() *Criteria

type DmlBase

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

func NewDmlBase

func NewDmlBase(DB IDb, table *Table) *DmlBase

func (*DmlBase) GetAliasForAssociation

func (d *DmlBase) GetAliasForAssociation(association *Association) string

func (*DmlBase) GetCriteria

func (d *DmlBase) GetCriteria() *Criteria

func (*DmlBase) GetDb

func (d *DmlBase) GetDb() IDb

func (*DmlBase) GetDba

func (d *DmlBase) GetDba() *dbx.SimpleDBA

func (*DmlBase) GetJoins

func (d *DmlBase) GetJoins() []*Join

func (*DmlBase) GetParameter

func (d *DmlBase) GetParameter(column *Column) interface{}

func (*DmlBase) GetParameters

func (d *DmlBase) GetParameters() map[string]interface{}

func (*DmlBase) GetTable

func (d *DmlBase) GetTable() *Table

func (*DmlBase) GetTableAlias

func (d *DmlBase) GetTableAlias() string

func (*DmlBase) NextRawIndex

func (d *DmlBase) NextRawIndex() int

func (*DmlBase) SetParameter

func (d *DmlBase) SetParameter(key string, parameter interface{})

func (*DmlBase) SetParameterFor

func (d *DmlBase) SetParameterFor(col *Column, parameter interface{})

Sets the value of parameter to the column param col: The column param parameter: The value to set

func (*DmlBase) SetTableAlias

func (d *DmlBase) SetTableAlias(alias string)

type DmlCore

type DmlCore struct {
	DmlBase
	// contains filtered or unexported fields
}

func (*DmlCore) GetValues

func (d *DmlCore) GetValues() coll.Map

type DmlType

type DmlType int
const (
	INSERT DmlType = iota
	UPDATE
	DELETE
	QUERY
)

type EntityProperty

type EntityProperty struct {
	StructProperty
	Position int
	Key      bool
}

func (*EntityProperty) ConvertFromDb

func (bp *EntityProperty) ConvertFromDb(value interface{}) (interface{}, error)

func (*EntityProperty) ConvertToDb

func (bp *EntityProperty) ConvertToDb(value interface{}) (interface{}, error)

func (*EntityProperty) Get

func (e *EntityProperty) Get(instance reflect.Value) reflect.Value

func (*EntityProperty) IsMany

func (e *EntityProperty) IsMany() bool

func (*EntityProperty) New

func (e *EntityProperty) New() interface{}

func (*EntityProperty) Set

func (e *EntityProperty) Set(instance reflect.Value, value reflect.Value) bool

Do not set nil values. If value is nil it will return false, otherwise returns true

type EntityTransformer

type EntityTransformer struct {
	Overrider    EntityTransformerOverrider
	Query        *Query
	Factory      func() reflect.Value
	Returner     func(val reflect.Value) reflect.Value
	Properties   map[string]*EntityProperty
	TemplateData []interface{}
}

func NewEntityFactoryTransformer

func NewEntityFactoryTransformer(query *Query, typ reflect.Type, returner func(val reflect.Value) reflect.Value) *EntityTransformer

func NewEntityTransformer

func NewEntityTransformer(query *Query, instance interface{}) *EntityTransformer

func (*EntityTransformer) AfterAll

func (e *EntityTransformer) AfterAll(result coll.Collection)

func (*EntityTransformer) BeforeAll

func (e *EntityTransformer) BeforeAll() coll.Collection

func (*EntityTransformer) DiscardIfKeyIsNull

func (e *EntityTransformer) DiscardIfKeyIsNull() bool

can be overriden

func (*EntityTransformer) InitRowData

func (e *EntityTransformer) InitRowData(
	row []interface{},
	properties map[string]*EntityProperty,
)

func (*EntityTransformer) OnTransformation

func (e *EntityTransformer) OnTransformation(result coll.Collection, instance interface{})

func (*EntityTransformer) PopulateMapping

func (e *EntityTransformer) PopulateMapping(tableAlias string, typ reflect.Type) (map[string]*EntityProperty, error)
	 Populates the mapping with instance properties, using "tableAlias.propertyName" as key
  Only properties of a type present in the query are mapped
	 param mappings: instance of Map
	 param tableAlias: The table alias. If <code>nil</code> the mapping key is only "propertyName"
	 param type: The entity class

func (*EntityTransformer) ToEntity

func (e *EntityTransformer) ToEntity(
	row []interface{},
	instance reflect.Value,
	properties map[string]*EntityProperty,
	emptyBean *bool,
) (bool, error)

returns if the entity was valid

func (*EntityTransformer) Transform

func (e *EntityTransformer) Transform(rows *sql.Rows) (interface{}, error)

type EntityTransformerOverrider

type EntityTransformerOverrider interface {
	dbx.IRowTransformer

	PopulateMapping(tableAlias string, typ reflect.Type) (map[string]*EntityProperty, error)
	DiscardIfKeyIsNull() bool
	InitRowData(row []interface{}, properties map[string]*EntityProperty)
	ToEntity(row []interface{}, instance reflect.Value, properties map[string]*EntityProperty, emptyBean *bool) (bool, error)
}

type EntityTreeTransformer

type EntityTreeTransformer struct {
	EntityTransformer
	// contains filtered or unexported fields
}

extends EntityTransformer

func NewEntityTreeFactoryTransformer

func NewEntityTreeFactoryTransformer(query *Query, typ reflect.Type, returner func(val reflect.Value) reflect.Value) *EntityTreeTransformer

since the creation of the list is managed outside the reue flag is set to false

func NewEntityTreeTransformer

func NewEntityTreeTransformer(query *Query, reuse bool, instance interface{}) *EntityTreeTransformer

func (*EntityTreeTransformer) AfterAll

func (e *EntityTreeTransformer) AfterAll(result coll.Collection)

func (*EntityTreeTransformer) BeforeAll

func (e *EntityTreeTransformer) BeforeAll() coll.Collection

func (*EntityTreeTransformer) DiscardIfKeyIsNull

func (e *EntityTreeTransformer) DiscardIfKeyIsNull() bool

func (*EntityTreeTransformer) ForwardBranches

func (e *EntityTreeTransformer) ForwardBranches() []*Association

return the list o current branches and moves forward to the next list return: the current list of branches

func (*EntityTreeTransformer) InitFullRowData

func (e *EntityTreeTransformer) InitFullRowData(
	row []interface{},
	typ reflect.Type,
	alias string,
) error

func (*EntityTreeTransformer) LoadInstanceKeys

func (e *EntityTreeTransformer) LoadInstanceKeys(
	row []interface{},
	ptr reflect.Value,
	properties map[string]*EntityProperty,
	onlyKeys bool,
) (bool, error)

return true if the entity is valid

func (*EntityTreeTransformer) OnTransformation

func (e *EntityTreeTransformer) OnTransformation(result coll.Collection, instance interface{})

func (*EntityTreeTransformer) Transform

func (e *EntityTreeTransformer) Transform(rows *sql.Rows) (interface{}, error)

type Group

type Group struct {
	Position int
	Token    Tokener
}

type HoldTable

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

type HollowTransactionManager

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

func (HollowTransactionManager) NoTransaction

func (t HollowTransactionManager) NoTransaction(handler func(db IDb) error) error

func (HollowTransactionManager) Store

func (t HollowTransactionManager) Store() IDb

func (HollowTransactionManager) Transaction

func (t HollowTransactionManager) Transaction(handler func(db IDb) error) error

func (HollowTransactionManager) With

type IDb

type IDb interface {
	PopulateMapping(prefix string, typ reflect.Type) (map[string]*EntityProperty, error)
	GetTranslator() Translator
	GetConnection() dbx.IConnection
	WithContext(context.Context) IDb
	GetContext() context.Context

	Query(table *Table) *Query
	Insert(table *Table) *Insert
	Delete(table *Table) *Delete
	Update(table *Table) *Update

	Create(instance interface{}) error
	Retrieve(instance interface{}, keys ...interface{}) (bool, error)
	FindFirst(instance interface{}, example interface{}) (bool, error)
	FindAll(instance interface{}, example interface{}) error
	Modify(instance interface{}) (bool, error)
	Remove(instance interface{}) (bool, error)
	RemoveAll(instance interface{}) (int64, error)
	Save(instance interface{}) (bool, error) // Create or Modify

	GetAttribute(string) (interface{}, bool)
	SetAttribute(string, interface{}) // general attribute. ex: user in session
}

type ITransactionManager

type ITransactionManager interface {
	With(db IDb) ITransactionManager
	Transaction(handler func(db IDb) error) error
	NoTransaction(handler func(db IDb) error) error
	Store() IDb
}

type Insert

type Insert struct {
	DmlCore

	HasKeyValue bool
	// contains filtered or unexported fields
}

func NewInsert

func NewInsert(db IDb, table *Table) *Insert

func (*Insert) Alias

func (i *Insert) Alias(alias string) *Insert

func (*Insert) Columns

func (i *Insert) Columns(columns ...*Column) *Insert

func (*Insert) Execute

func (i *Insert) Execute() (int64, error)

returns the last inserted id

func (*Insert) ReturnId

func (i *Insert) ReturnId(returnId bool) *Insert

Definies if the auto key should be retrieved. Returning an Id could mean one more query execution. It returns the Id by default.

func (*Insert) Set

func (i *Insert) Set(col *Column, value interface{}) *Insert

func (*Insert) Submit

func (i *Insert) Submit(instance interface{}) (int64, error)

Loads sets all the columns of the table to matching bean property

param instance: The instance to match return this

func (*Insert) Values

func (i *Insert) Values(vals ...interface{}) *Insert

type Join

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

func NewJoin

func NewJoin(associations []*PathElement, fetch bool) *Join

func (Join) GetAssociations

func (j Join) GetAssociations() []*Association

func (Join) GetPathElements

func (j Join) GetPathElements() []*PathElement

func (Join) IsFetch

func (j Join) IsFetch() bool

type Mapper added in v1.5.0

type Mapper interface {
	Mappings(typ reflect.Type) (map[string]*StructProperty, error)
}

type Markable

type Markable interface {
	// Retrieve property names that were changed
	//
	// return names of the changed properties
	Marks() map[string]bool
	Unmark()
}

Interface that a struct must implement to inform what columns where changed

type Marker

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

func (*Marker) Mark

func (m *Marker) Mark(mark string)

func (*Marker) Marks

func (m *Marker) Marks() map[string]bool

func (*Marker) Unmark

func (m *Marker) Unmark()

type MyTx

type MyTx struct {
	*sql.Tx
}

type NoTx

type NoTx struct {
	*sql.DB
}

type Order

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

func NewOrder

func NewOrder(column *ColumnHolder) *Order

func NewOrderAs

func NewOrderAs(alias string) *Order

func (*Order) Asc

func (o *Order) Asc(asc bool) *Order

func (Order) GetAlias

func (o Order) GetAlias() string

func (*Order) GetHolder

func (o *Order) GetHolder() *ColumnHolder

func (*Order) IsAsc

func (o *Order) IsAsc() bool

type ParsedSql

type ParsedSql struct {
	Names []string
	// indexes for the specified parameter.
	Indexes [][]int
	// contains filtered or unexported fields
}

Holds information about a parsed SQL statement.

func NewParsedSql

func NewParsedSql(sql string) *ParsedSql

param originalSql: the SQL statement that is being (or is to be) parsed

func ParseSqlStatement

func ParseSqlStatement(statement string) *ParsedSql

Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a native placeholder.

param statement: the SQL statement return: the parsed statement, represented as ParsedSql instance

func (*ParsedSql) AddNamedParameter

func (p *ParsedSql) AddNamedParameter(name string, startIndex int, endIndex int)

Add a named parameter parsed from this SQL statement.

param name: the name of the parameter param startIndex: the start index in the original SQL String param endIndex: the end index in the original SQL String

func (ParsedSql) String

func (p ParsedSql) String() string

type PathCriteria

type PathCriteria struct {
	Criterias []*Criteria
	Columns   []Tokener
}

type PathElement

type PathElement struct {
	Base           *Association
	Derived        *Association
	Inner          bool
	Criteria       *Criteria
	Columns        []Tokener
	Orders         []*Order
	PreferredAlias string // user preferred alias
}

func DeepestCommonPath

func DeepestCommonPath(cachedAssociation [][]*PathElement, associations []*PathElement) []*PathElement

From the lists of Foreign Keys (paths) groups, gets the Foreign Keys matching the longest common path that is possible to traverse with the supplied Foreign Keys param cachedAssociation: lists of Foreign Keys (paths) groups param associations: matching Foreign Keys (paths) groups return Foreign Keys: matching the longest common path that is possible to traverse

type PostDeleter

type PostDeleter interface {
	PostDelete(store IDb) error
}

type PostInserter

type PostInserter interface {
	PostInsert(store IDb)
}

type PostRetriever added in v1.3.0

type PostRetriever interface {
	PostRetrieve(store IDb)
}

type PostUpdater

type PostUpdater interface {
	PostUpdate(store IDb)
}

type PreDeleter

type PreDeleter interface {
	PreDelete(store IDb) error
}

type PreInserter

type PreInserter interface {
	PreInsert(store IDb) error
}

type PreUpdater

type PreUpdater interface {
	PreUpdate(store IDb) error
}

type Query

type Query struct {
	DmlBase

	Columns []Tokener
	// contains filtered or unexported fields
}

func NewQuery

func NewQuery(db IDb, table *Table) *Query

func NewQueryQuery

func NewQueryQuery(subquery *Query) *Query

func NewQueryQueryAs

func NewQueryQueryAs(subquery *Query, subQueryAlias string) *Query

func (*Query) Alias

func (q *Query) Alias(alias string) *Query

func (*Query) All

func (q *Query) All() *Query

func (*Query) As

func (q *Query) As(alias string) *Query

Defines the alias of the last column param alias: The Alias return: The query

func (*Query) Asc

func (q *Query) Asc() *Query

func (*Query) Column

func (q *Query) Column(columns ...interface{}) *Query

func (*Query) ColumnsReset

func (q *Query) ColumnsReset()

func (*Query) Copy

func (q *Query) Copy(other *Query)

func (*Query) Count

func (q *Query) Count(column interface{}) *Query

func (*Query) CountAll

func (q *Query) CountAll() *Query

func (*Query) Desc

func (q *Query) Desc() *Query

func (*Query) Dir

func (q *Query) Dir(asc bool) *Query

Sets the order direction for the last order by command. true=asc, false=desc

func (*Query) Distinct

func (q *Query) Distinct() *Query

func (*Query) Fetch

func (q *Query) Fetch() *Query

This will trigger a result that can be dumped in a tree object using current association path to build the tree result.

It will includes all the columns of all the tables referred by the association path, except where columns were explicitly included.

func (*Query) GetGroupBy

func (q *Query) GetGroupBy() []int

func (*Query) GetGroupByTokens

func (q *Query) GetGroupByTokens() []Group

func (*Query) GetHaving

func (q *Query) GetHaving() *Criteria

func (*Query) GetLimit

func (q *Query) GetLimit() int64

func (*Query) GetOrders

func (q *Query) GetOrders() []*Order

func (*Query) GetSkip

func (q *Query) GetSkip() int64

func (*Query) GetSubQuery

func (q *Query) GetSubQuery() *Query

func (*Query) GetSubQueryAlias

func (q *Query) GetSubQueryAlias() string

func (*Query) GetUnions

func (q *Query) GetUnions() []*Union

func (*Query) GroupBy

func (q *Query) GroupBy(cols ...*Column) *Query

func (*Query) GroupByAs

func (q *Query) GroupByAs(aliases ...string) *Query

func (*Query) GroupByPos

func (q *Query) GroupByPos(pos ...int) *Query

func (*Query) GroupByUntil

func (q *Query) GroupByUntil(untilPos int) *Query

GROUP BY ===

func (*Query) Having

func (q *Query) Having(having ...*Criteria) *Query

Adds a Having clause to the query. The tokens are not processed. You will have to explicitly set all table alias.

func (*Query) Include

func (q *Query) Include(columns ...interface{}) *Query

adds tokens refering the last defined association

func (*Query) Inner

func (q *Query) Inner(associations ...*Association) *Query

includes the associations as inner joins to the current path

param: associations
return this query

func (*Query) IsDistinct

func (q *Query) IsDistinct() bool

func (*Query) Join

func (q *Query) Join() *Query

indicates that the path should be used to join only

func (*Query) Limit

func (q *Query) Limit(limit int64) *Query

func (*Query) List

func (q *Query) List(target interface{}) error

List executes a query, putting the result in a slice, passed as an argument or delegating the responsibility of building the result to a processor function.

The argument must be a function func(<<*>struct>) or a slice like *[]<*>struct.

example of function:

books := []Book
q := // query
q.List(func(b *Book) {
  books = append(books, b)
})

This method does not create a tree of related instances.

func (*Query) ListFlatTree

func (q *Query) ListFlatTree(target interface{}) error

ListFlatTree executes a query, putting the result in a slice, passed as an argument or delegating the responsibility of building the result to a processor function.

The argument must be a function func(<<*>struct>) or a slice like *[]<*>struct.

See List for non tree query

func (*Query) ListFlatTreeOf

func (q *Query) ListFlatTreeOf(template interface{}) (coll.Collection, error)

Executes a query and transform the results into a flat tree with the passed struct type as the head. It matches the alias with struct property name, building a struct tree. There is no reuse of previous converted entites.

Receives a template instance and returns a collection of structs.

func (*Query) ListInto

func (q *Query) ListInto(closure interface{}) ([]interface{}, error)

List using the closure arguments.

A function is used to build the result list.

The types for scanning are supplied by the function arguments. Arguments can be pointers or not.

Reflection is used to determine the arguments types.

The argument can also be a function with the signature func(*struct).

The results will not be assembled in as a tree.

ex:

  roles = make([]string, 0)
  var role string
  q.ListInto(func(role *string) {
	   roles = append(roles, *role)
  })

func (*Query) ListOf

func (q *Query) ListOf(template interface{}) (coll.Collection, error)

Executes a query and transform the results to the struct type passed as parameter, matching the alias with struct property name. If no alias is supplied, it is used the default column alias.

Accepts as parameter the struct type and returns a collection of structs (needs cast)

func (*Query) ListSimple

func (q *Query) ListSimple(closure func(), instances ...interface{}) error

List simple variables. A closure is used to build the result list. The types for scanning are supplied by the instances parameter. No reflection is used.

ex:

roles = make([]string, 0)
var role string
q.ListSimple(func() {
	roles = append(roles, role)
}, &role)

func (*Query) ListTreeOf

func (q *Query) ListTreeOf(template tk.Hasher) (coll.Collection, error)

Executes a query and transform the results into a tree with the passed struct type as the head. It matches the alias with struct property name, building a struct tree. If the transformed data matches a previous converted entity the previous one is reused.

Receives a template instance and returns a collection of structs.

func (*Query) On

func (q *Query) On(criteria ...*Criteria) *Query

Restriction to apply to the previous association

func (*Query) Order

func (q *Query) Order(column *Column) *Query

Order by a column belonging to the driving table.

func (*Query) OrderAs

func (q *Query) OrderAs(columnHolder *ColumnHolder) *Query

Order by a column for a specific table alias.

use: query.OrderAs(Column.For("x"))

func (*Query) OrderBy

func (q *Query) OrderBy(column *Column) *Query

Defines the column to order by. The column belongs to the table targeted by the last defined association. If there is no last association, the column belongs to the driving table

func (*Query) OrderByAs

func (q *Query) OrderByAs(column string) *Query

Defines the column alias to order by.

func (*Query) OrderOn

func (q *Query) OrderOn(column *Column, associations ...*Association) *Query

Order by a column belonging to the table targeted by the supplyied association list.

func (*Query) OrdersReset

func (q *Query) OrdersReset()

ORDER ===

func (*Query) Outer

func (q *Query) Outer(associations ...*Association) *Query

includes the associations as outer joins to the current path

param associations
return

func (*Query) SelectFlatTree

func (q *Query) SelectFlatTree(instance interface{}) (bool, error)

Executes the query and builds a flat struct tree putting the first element in the supplied struct pointer. Since the struct instances are not going to be reused it is not mandatory that the structs implement the toolkit.Hasher interface. Returns true if a result was found, false if no result. See also SelectTree.

func (*Query) SelectInto

func (q *Query) SelectInto(dest ...interface{}) (bool, error)

the result of the query is put in the passed interface array. returns true if a result was found, false if no result

func (*Query) SelectTo

func (q *Query) SelectTo(instance interface{}) (bool, error)

The first result of the query is put in the passed struct. Returns true if a result was found, false if no result

func (*Query) SelectTree

func (q *Query) SelectTree(instance tk.Hasher) (bool, error)

Executes the query and builds a struct tree, reusing previously obtained entities, putting the first element in the supplied struct pointer. Since the struct instances are going to be reused it is mandatory that all the structs participating in the result tree implement the toolkit.Hasher interface. Returns true if a result was found, false if no result. See also SelectFlatTree.

func (*Query) Skip

func (q *Query) Skip(skip int64) *Query

func (*Query) Union

func (q *Query) Union(query *Query) *Query

UNIONS ===

func (*Query) UnionAll

func (q *Query) UnionAll(query *Query) *Query

func (*Query) Where

func (q *Query) Where(restriction ...*Criteria) *Query

WHERE ===

type RawSql

type RawSql struct {
	// original sql
	OriSql string
	// the converted SQL with the Database specific placeholders
	Sql string
	// the parameters values
	Names []string
}

func ToRawSql

func ToRawSql(sql string, translator Translator) *RawSql

converts SQL with named parameters to the specialized Database placeholders

param sql

The SQL to be converted

param params

The named parameters and it's values

@return The {@link RawSql} with the result

func (*RawSql) BuildValues

func (r *RawSql) BuildValues(paramMap map[string]interface{}) ([]interface{}, error)

Convert a Map of named parameter values to a corresponding array.

return the array of values

func (*RawSql) Clone

func (r *RawSql) Clone() interface{}

type Relashionships

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

func (Relashionships) As

func (r Relashionships) As(alias string) *Association

func (Relashionships) Fault added in v1.4.0

func (r Relashionships) Fault() error

type Relation

type Relation struct {
	From *ColumnHolder
	To   *ColumnHolder
}

func NewRelation

func NewRelation(from *Column, to *Column) Relation

func (Relation) String

func (r Relation) String() string

type SearchedCase

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

func NewSearchedCase

func NewSearchedCase() *SearchedCase

func (*SearchedCase) Else

func (s *SearchedCase) Else(value interface{}) *SearchedCase

func (*SearchedCase) End

func (s *SearchedCase) End() *Token

func (*SearchedCase) If

func (s *SearchedCase) If(criteria *Criteria) *SearchedWhen

type SearchedWhen

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

func If

func If(criteria *Criteria) *SearchedWhen

func (*SearchedWhen) Then

func (s *SearchedWhen) Then(value interface{}) *SearchedCase

type SimpleCase

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

func Case

func Case(expression interface{}) *SimpleCase

func NewSimpleCase

func NewSimpleCase(expression interface{}) *SimpleCase

func (*SimpleCase) Else

func (s *SimpleCase) Else(value interface{}) *SimpleCase

func (*SimpleCase) End

func (s *SimpleCase) End() *Token

func (*SimpleCase) When

func (s *SimpleCase) When(expression interface{}) *SimpleWhen

type SimpleWhen

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

func (*SimpleWhen) Then

func (s *SimpleWhen) Then(value interface{}) *SimpleCase

type StructProperty added in v1.4.2

type StructProperty struct {
	Type      reflect.Type
	InnerType reflect.Type
	Omit      bool
	// contains filtered or unexported fields
}

type Table

type Table struct {
	Alias string // table alias

	PreInsertTrigger func(*Insert)
	PreUpdateTrigger func(*Update)
	PreDeleteTrigger func(*Delete)
	// contains filtered or unexported fields
}

func TABLE

func TABLE(name string) *Table

func (*Table) ASSOCIATE

func (t *Table) ASSOCIATE(from ...*Column) ColGroup

func (*Table) ASSOCIATION

func (t *Table) ASSOCIATION(from *Column, to *Column) *Association

func (*Table) AddAssociation

func (t *Table) AddAssociation(fk *Association) *Association

func (*Table) AddAssociationAs

func (t *Table) AddAssociationAs(name string, fk *Association) *Association

func (*Table) As

func (t *Table) As(alias string) *Table

func (*Table) COLUMN

func (t *Table) COLUMN(name string) *Column

func (*Table) DELETION

func (t *Table) DELETION(name string) *Column

func (*Table) Equals

func (t *Table) Equals(obj interface{}) bool

func (*Table) GetAssociations

func (t *Table) GetAssociations() []*Association

func (*Table) GetBasicColumns

func (t *Table) GetBasicColumns() coll.Collection

func (*Table) GetColumns

func (t *Table) GetColumns() coll.Collection

gets column list

func (*Table) GetCriterias

func (t *Table) GetCriterias() []*Criteria

func (*Table) GetDeletionColumn

func (t *Table) GetDeletionColumn() *Column

func (*Table) GetDiscriminators

func (t *Table) GetDiscriminators() []Discriminator

func (*Table) GetKeyColumns

func (t *Table) GetKeyColumns() coll.Collection

func (*Table) GetName

func (t *Table) GetName() string

gets the table name

func (*Table) GetSingleKeyColumn

func (t *Table) GetSingleKeyColumn() *Column

func (*Table) GetVersionColumn

func (t *Table) GetVersionColumn() *Column

func (*Table) KEY

func (t *Table) KEY(name string) *Column

func (*Table) String

func (t *Table) String() string

func (*Table) VERSION

func (t *Table) VERSION(name string) *Column

func (*Table) With

func (t *Table) With(column string, value interface{}) *Table

type TableNamer added in v1.3.0

type TableNamer interface {
	TableName() string
}

type Token

type Token struct {
	Operator string
	Members  []Tokener
	Value    interface{}
	Alias    string
	// contains filtered or unexported fields
}

func Add

func Add(values ...interface{}) *Token

the args can be Columns, Tokens, nil or primitives

func Alias

func Alias(s string) *Token

func AsIs

func AsIs(o interface{}) *Token

func Coalesce

func Coalesce(values ...interface{}) *Token

func Count

func Count(column interface{}) *Token

pass nil to ignore column

func Lower

func Lower(token interface{}) *Token

func Max

func Max(token interface{}) *Token

func Min

func Min(token interface{}) *Token

func Minus

func Minus(values ...interface{}) *Token

the args can be Columns, Tokens, nil or primitives

func Multiply

func Multiply(values ...interface{}) *Token

the args can be Columns, Tokens, nil or primitives

func NewEndToken

func NewEndToken(operator string, o interface{}) *Token

func NewToken

func NewToken(operator string, members ...interface{}) *Token

func Null

func Null() *Token

func Param

func Param(str string) *Token

FUNCTION =======================

func Raw

func Raw(o interface{}) *Token

func Rtrim

func Rtrim(token interface{}) *Token

func SubQuery

func SubQuery(sq *Query) *Token

func Sum

func Sum(token interface{}) *Token

func Upper

func Upper(token interface{}) *Token

func (*Token) Clone

func (t *Token) Clone() interface{}

func (*Token) Different

func (t *Token) Different(value interface{}) *Criteria

func (*Token) Equals

func (t *Token) Equals(o interface{}) bool

func (*Token) GetAlias

func (t *Token) GetAlias() string

func (*Token) GetMembers

func (t *Token) GetMembers() []Tokener

func (*Token) GetOperator

func (t *Token) GetOperator() string

func (*Token) GetPseudoTableAlias

func (t *Token) GetPseudoTableAlias() string

func (*Token) GetTableAlias

func (t *Token) GetTableAlias() string

func (*Token) GetValue

func (t *Token) GetValue() interface{}

func (*Token) Greater

func (t *Token) Greater(value interface{}) *Criteria

func (*Token) GreaterOrMatch

func (t *Token) GreaterOrMatch(value interface{}) *Criteria

func (*Token) HashCode

func (t *Token) HashCode() int

func (*Token) ILike

func (t *Token) ILike(right interface{}) *Criteria

func (*Token) IMatches

func (t *Token) IMatches(value interface{}) *Criteria

func (*Token) IsNil

func (t *Token) IsNil() bool

func (*Token) IsNull

func (t *Token) IsNull() *Criteria

func (*Token) Lesser

func (t *Token) Lesser(value interface{}) *Criteria

func (*Token) LesserOrMatch

func (t *Token) LesserOrMatch(value interface{}) *Criteria

func (*Token) Like

func (t *Token) Like(right interface{}) *Criteria

func (*Token) Matches

func (t *Token) Matches(value interface{}) *Criteria

func (*Token) SetAlias

func (t *Token) SetAlias(alias string)

func (*Token) SetMembers

func (t *Token) SetMembers(members ...Tokener)

func (*Token) SetOperator

func (t *Token) SetOperator(operator string)

func (*Token) SetPseudoTableAlias

func (t *Token) SetPseudoTableAlias(pseudoTableAlias string)

func (*Token) SetTableAlias

func (t *Token) SetTableAlias(tableAlias string)

Propagates table alias

func (*Token) SetValue

func (t *Token) SetValue(value interface{})

func (*Token) String

func (t *Token) String() string

type Tokener

type Tokener interface {
	tk.Clonable

	GetAlias() string
	SetAlias(alias string)
	SetTableAlias(tableAlias string)
	GetTableAlias() string
	SetPseudoTableAlias(tableAlias string)
	GetPseudoTableAlias() string
	IsNil() bool
	GetMembers() []Tokener
	SetMembers(members ...Tokener)
	SetValue(value interface{})
	GetValue() interface{}
	GetOperator() string
	SetOperator(operator string)
}

type TransactionManager

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

func NewTransactionManager

func NewTransactionManager(database *sql.DB, translator Translator, options ...func(*TransactionManager)) *TransactionManager

NewTransactionManager creates a new Transaction Manager

func (*TransactionManager) Mappings added in v1.5.0

func (t *TransactionManager) Mappings(typ reflect.Type) (map[string]*StructProperty, error)

func (*TransactionManager) NoTransaction

func (t *TransactionManager) NoTransaction(handler func(db IDb) error) error

func (*TransactionManager) RegisterType added in v1.5.0

func (d *TransactionManager) RegisterType(v interface{}) error

func (*TransactionManager) Store

func (t *TransactionManager) Store() IDb

func (*TransactionManager) Transaction

func (t *TransactionManager) Transaction(handler func(db IDb) error) error

func (*TransactionManager) With

type Translator

type Translator interface {
	GetPlaceholder(index int, name string) string
	// INSERT
	GetAutoKeyStrategy() AutoKeyStrategy
	GetSqlForInsert(insert *Insert) string
	// QUERY
	GetSqlForQuery(query *Query) string
	// UPDATE
	GetSqlForUpdate(update *Update) string
	// DELTE
	GetSqlForDelete(del *Delete) string
	// GetSqlForSequence(sequence *Sequence, nextValue bool) string
	GetAutoNumberQuery(column *Column) string
	//	GetMaxTableChars() int
	PaginateSQL(query *Query, sql string) string
	Translate(dmlType DmlType, token Tokener) (string, error)
	TableName(table *Table) string
	ColumnName(column *Column) string
	ColumnAlias(token Tokener, position int) string
	IgnoreNullKeys() bool
	RegisterConverter(name string, c Converter)
	GetConverter(name string) Converter
}

type Union

type Union struct {
	Query *Query
	All   bool
}

func (*Union) Equals

func (u *Union) Equals(o interface{}) bool

type Update

type Update struct {
	DmlCore
}

func NewUpdate

func NewUpdate(db IDb, table *Table) *Update

func (*Update) Alias

func (u *Update) Alias(alias string) *Update

func (*Update) Columns

func (u *Update) Columns(columns ...*Column) *Update

func (*Update) Execute

func (u *Update) Execute() (int64, error)

returns the number of affected rows

func (*Update) Set

func (u *Update) Set(col *Column, value interface{}) *Update

func (*Update) Submit

func (u *Update) Submit(instance interface{}) (int64, error)

Updates all the columns of the table to matching struct fields. Returns the number of affected rows

func (*Update) Values

func (u *Update) Values(vals ...interface{}) *Update

func (*Update) Where

func (u *Update) Where(restriction ...*Criteria) *Update

Jump to

Keyboard shortcuts

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