Documentation ¶
Overview ¶
WIP: A version of the builder which accumulates errors, we'll see if we can't unify the implementations at some point WIP Under Construction WIP Under Really Heavy Construction WIP Under Construction WIP Under Really Heavy Construction WIP Under Construction
* * Query Generator Library * WIP Under Construction * Copyright Azareal 2017 - 2020 *
Index ¶
- Constants
- Variables
- func InterfaceMapToInsertStrings(data map[string]interface{}, order string) (cols, values string)
- type AccBuilder
- type AccExec
- type AccRowWrap
- type AccSelectBuilder
- func (b *AccSelectBuilder) Cols(cols string) *AccSelectBuilder
- func (b *AccSelectBuilder) Columns(cols string) *AccSelectBuilder
- func (b *AccSelectBuilder) ComplexPrepare() *sql.Stmt
- func (b *AccSelectBuilder) DateCutoff(col string, quantity int, unit string) *AccSelectBuilder
- func (b *AccSelectBuilder) DateOlderThanQ(col, unit string) *AccSelectBuilder
- func (b *AccSelectBuilder) Each(h func(*sql.Rows) error) error
- func (b *AccSelectBuilder) EachInt(h func(int) error) error
- func (b *AccSelectBuilder) EachP(h func(*sql.Rows) error, p ...interface{}) error
- func (b *AccSelectBuilder) In(col string, inList []int) *AccSelectBuilder
- func (b *AccSelectBuilder) InPQuery(col string, inList []int) (*sql.Rows, error)
- func (b *AccSelectBuilder) InQ(col string, sb *AccSelectBuilder) *AccSelectBuilder
- func (b *AccSelectBuilder) Limit(limit string) *AccSelectBuilder
- func (b *AccSelectBuilder) Orderby(orderby string) *AccSelectBuilder
- func (b *AccSelectBuilder) Prepare() *sql.Stmt
- func (b *AccSelectBuilder) Query(args ...interface{}) (*sql.Rows, error)
- func (b *AccSelectBuilder) QueryRow(args ...interface{}) *AccRowWrap
- func (b *AccSelectBuilder) Stmt() *sql.Stmt
- func (b *AccSelectBuilder) Where(where string) *AccSelectBuilder
- type Accumulator
- func (acc *Accumulator) BulkInsert(table string) *accBulkInsertBuilder
- func (acc *Accumulator) Count(table string) *accCountBuilder
- func (acc *Accumulator) CreateTable(table, charset, collation string, columns []DBTableColumn, keys []DBTableKey) *sql.Stmt
- func (acc *Accumulator) CreateTableTx(tx *sql.Tx, table, charset, collation string, columns []DBTableColumn, ...) (stmt *sql.Stmt)
- func (acc *Accumulator) Delete(table string) *accDeleteBuilder
- func (acc *Accumulator) Exists(tbl, col string) *AccSelectBuilder
- func (acc *Accumulator) FirstError() error
- func (acc *Accumulator) GetAdapter() Adapter
- func (acc *Accumulator) Insert(table string) *accInsertBuilder
- func (acc *Accumulator) Model(table string) *accModelBuilder
- func (acc *Accumulator) Purge(table string) *sql.Stmt
- func (acc *Accumulator) PurgeTx(tx *sql.Tx, table string) (stmt *sql.Stmt)
- func (acc *Accumulator) RawPrepare(res string) *sql.Stmt
- func (acc *Accumulator) RecordError(err error)
- func (acc *Accumulator) Select(table string) *AccSelectBuilder
- func (acc *Accumulator) SetAdapter(name string) error
- func (acc *Accumulator) SetConn(conn *sql.DB)
- func (acc *Accumulator) SimpleBulkInsert(table, cols string, fieldSet []string) *sql.Stmt
- func (acc *Accumulator) SimpleCount(table, where, limit string) *sql.Stmt
- func (acc *Accumulator) SimpleCountTx(tx *sql.Tx, table, where, limit string) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleDelete(table, where string) *sql.Stmt
- func (acc *Accumulator) SimpleDeleteTx(tx *sql.Tx, table, where string) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleInnerJoin(table1, table2, columns, joiners, where, orderby, limit string) *sql.Stmt
- func (acc *Accumulator) SimpleInnerJoinTx(tx *sql.Tx, table1, table2, columns, joiners, where, orderby, limit string) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleInsert(table, columns, fields string) *sql.Stmt
- func (acc *Accumulator) SimpleInsertInnerJoin(ins DBInsert, sel DBJoin) *sql.Stmt
- func (acc *Accumulator) SimpleInsertInnerJoinTx(tx *sql.Tx, ins DBInsert, sel DBJoin) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleInsertLeftJoin(ins DBInsert, sel DBJoin) *sql.Stmt
- func (acc *Accumulator) SimpleInsertLeftJoinTx(tx *sql.Tx, ins DBInsert, sel DBJoin) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleInsertSelect(ins DBInsert, sel DBSelect) *sql.Stmt
- func (acc *Accumulator) SimpleInsertSelectTx(tx *sql.Tx, ins DBInsert, sel DBSelect) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleInsertTx(tx *sql.Tx, table, columns, fields string) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleLeftJoin(table1, table2, columns, joiners, where, orderby, limit string) *sql.Stmt
- func (acc *Accumulator) SimpleLeftJoinTx(tx *sql.Tx, table1, table2, columns, joiners, where, orderby, limit string) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleModel(tbl, colstr, primary string) SimpleModel
- func (acc *Accumulator) SimpleSelect(table, columns, where, orderby, limit string) *sql.Stmt
- func (acc *Accumulator) SimpleSelectTx(tx *sql.Tx, table, columns, where, orderby, limit string) (stmt *sql.Stmt)
- func (acc *Accumulator) SimpleUpdate(table, set, where string) *sql.Stmt
- func (acc *Accumulator) SimpleUpdateSelect(table, set, table2, cols, where, orderby, limit string) *sql.Stmt
- func (acc *Accumulator) SimpleUpdateTx(tx *sql.Tx, table, set, where string) (stmt *sql.Stmt)
- func (acc *Accumulator) Tx(handler func(*TransactionBuilder) error)
- func (acc *Accumulator) Update(table string) *accUpdateBuilder
- type Adapter
- type DBColumn
- type DBField
- type DBInsert
- type DBInstallInstruction
- type DBInstallTable
- type DBJoin
- type DBJoiner
- type DBLimit
- type DBOrder
- type DBSelect
- type DBSetter
- type DBStmt
- type DBTableColumn
- type DBTableKey
- type DBToken
- type DBWhere
- type LitStr
- type MssqlAdapter
- func (a *MssqlAdapter) AddColumn(name, table string, column DBTableColumn, key *DBTableKey) (string, error)
- func (a *MssqlAdapter) AddForeignKey(name, table, column, ftable, fcolumn string, cascade bool) (out string, e error)
- func (a *MssqlAdapter) AddIndex(name, table, iname, colname string) (string, error)
- func (a *MssqlAdapter) AddKey(name, table, column string, key DBTableKey) (string, error)
- func (a *MssqlAdapter) BuildConn(config map[string]string) (*sql.DB, error)
- func (a *MssqlAdapter) Builder() *prebuilder
- func (a *MssqlAdapter) ChangeColumn(name, table, colName string, col DBTableColumn) (string, error)
- func (a *MssqlAdapter) ComplexDelete(b *deletePrebuilder) (string, error)
- func (a *MssqlAdapter) ComplexSelect(preBuilder *selectPrebuilder) (string, error)
- func (a *MssqlAdapter) CreateTable(name, table, charset, collation string, columns []DBTableColumn, ...) (string, error)
- func (a *MssqlAdapter) DbVersion() string
- func (a *MssqlAdapter) DropColumn(name, table, colName string) (string, error)
- func (a *MssqlAdapter) DropTable(name, table string) (string, error)
- func (a *MssqlAdapter) GetName() string
- func (a *MssqlAdapter) GetStmt(name string) DBStmt
- func (a *MssqlAdapter) GetStmts() map[string]DBStmt
- func (a *MssqlAdapter) Purge(name string, table string) (string, error)
- func (a *MssqlAdapter) RemoveIndex(name, table, iname string) (string, error)
- func (a *MssqlAdapter) RenameColumn(name, table, oldName, newName string) (string, error)
- func (a *MssqlAdapter) SetDefaultColumn(name, table, colName, colType, defaultStr string) (string, error)
- func (a *MssqlAdapter) SetPrimaryKeys(keys map[string]string)
- func (a *MssqlAdapter) SimpleBulkInsert(name, table, cols string, fieldSet []string) (string, error)
- func (a *MssqlAdapter) SimpleCount(name, table, where, limit string) (string, error)
- func (a *MssqlAdapter) SimpleDelete(name string, table string, where string) (string, error)
- func (a *MssqlAdapter) SimpleInnerJoin(name string, table1 string, table2 string, columns string, joiners string, ...) (string, error)
- func (a *MssqlAdapter) SimpleInsert(name, table, cols, fields string) (string, error)
- func (a *MssqlAdapter) SimpleInsertInnerJoin(name string, ins DBInsert, sel DBJoin) (string, error)
- func (a *MssqlAdapter) SimpleInsertLeftJoin(name string, ins DBInsert, sel DBJoin) (string, error)
- func (a *MssqlAdapter) SimpleInsertSelect(name string, ins DBInsert, sel DBSelect) (string, error)
- func (a *MssqlAdapter) SimpleLeftJoin(name string, table1 string, table2 string, columns string, joiners string, ...) (string, error)
- func (a *MssqlAdapter) SimpleReplace(name, table, columns, fields string) (string, error)
- func (a *MssqlAdapter) SimpleSelect(name string, table string, columns string, where string, orderby string, ...) (string, error)
- func (a *MssqlAdapter) SimpleUpdate(up *updatePrebuilder) (string, error)
- func (a *MssqlAdapter) SimpleUpdateSelect(b *updatePrebuilder) (string, error)
- func (a *MssqlAdapter) SimpleUpsert(name, table, columns, fields, where string) (string, error)
- func (a *MssqlAdapter) Write() error
- type MySQLUpsertCallback
- type MysqlAdapter
- func (a *MysqlAdapter) AddColumn(name, table string, col DBTableColumn, key *DBTableKey) (string, error)
- func (a *MysqlAdapter) AddForeignKey(name, table, col, ftable, fcolumn string, cascade bool) (out string, e error)
- func (a *MysqlAdapter) AddIndex(name, table, iname, colname string) (string, error)
- func (a *MysqlAdapter) AddKey(name, table, cols string, key DBTableKey) (string, error)
- func (a *MysqlAdapter) BuildConn(config map[string]string) (*sql.DB, error)
- func (a *MysqlAdapter) Builder() *prebuilder
- func (a *MysqlAdapter) ChangeColumn(name, table, colName string, col DBTableColumn) (string, error)
- func (a *MysqlAdapter) ComplexDelete(b *deletePrebuilder) (string, error)
- func (a *MysqlAdapter) ComplexSelect(preBuilder *selectPrebuilder) (out string, e error)
- func (a *MysqlAdapter) CreateTable(name, table, charset, collation string, cols []DBTableColumn, ...) (string, error)
- func (a *MysqlAdapter) DbVersion() string
- func (a *MysqlAdapter) DropColumn(name, table, colName string) (string, error)
- func (a *MysqlAdapter) DropTable(name, table string) (string, error)
- func (a *MysqlAdapter) GetName() string
- func (a *MysqlAdapter) GetStmt(name string) DBStmt
- func (a *MysqlAdapter) GetStmts() map[string]DBStmt
- func (a *MysqlAdapter) Purge(name, table string) (string, error)
- func (a *MysqlAdapter) RemoveIndex(name, table, iname string) (string, error)
- func (a *MysqlAdapter) RenameColumn(name, table, oldName, newName string) (string, error)
- func (a *MysqlAdapter) SetDefaultColumn(name, table, colName, colType, defaultStr string) (string, error)
- func (a *MysqlAdapter) SimpleBulkInsert(name, table, cols string, fieldSet []string) (string, error)
- func (a *MysqlAdapter) SimpleCount(name, table, where, limit string) (q string, e error)
- func (a *MysqlAdapter) SimpleDelete(name, table, where string) (string, error)
- func (a *MysqlAdapter) SimpleInnerJoin(name, table1, table2, columns, joiners, where, orderby, limit string) (string, error)
- func (a *MysqlAdapter) SimpleInsert(name, table, cols, fields string) (string, error)
- func (a *MysqlAdapter) SimpleInsertInnerJoin(name string, ins DBInsert, sel DBJoin) (string, error)
- func (a *MysqlAdapter) SimpleInsertLeftJoin(name string, ins DBInsert, sel DBJoin) (string, error)
- func (a *MysqlAdapter) SimpleInsertSelect(name string, ins DBInsert, sel DBSelect) (string, error)
- func (a *MysqlAdapter) SimpleLeftJoin(name, table1, table2, columns, joiners, where, orderby, limit string) (string, error)
- func (a *MysqlAdapter) SimpleReplace(name, table, cols, fields string) (string, error)
- func (a *MysqlAdapter) SimpleSelect(name, table, cols, where, orderby, limit string) (string, error)
- func (a *MysqlAdapter) SimpleUpdate(up *updatePrebuilder) (string, error)
- func (a *MysqlAdapter) SimpleUpdateSelect(up *updatePrebuilder) (string, error)
- func (a *MysqlAdapter) SimpleUpsert(name, table, columns, fields, where string) (string, error)
- func (a *MysqlAdapter) Write() error
- type PgsqlAdapter
- func (a *PgsqlAdapter) AddColumn(name, table string, column DBTableColumn, key *DBTableKey) (string, error)
- func (a *PgsqlAdapter) AddForeignKey(name, table, column, ftable, fcolumn string, cascade bool) (out string, e error)
- func (a *PgsqlAdapter) AddIndex(name, table, iname, colname string) (string, error)
- func (a *PgsqlAdapter) AddKey(name, table, column string, key DBTableKey) (string, error)
- func (a *PgsqlAdapter) BuildConn(config map[string]string) (*sql.DB, error)
- func (a *PgsqlAdapter) Builder() *prebuilder
- func (a *PgsqlAdapter) ChangeColumn(name, table, colName string, col DBTableColumn) (string, error)
- func (a *PgsqlAdapter) ComplexDelete(b *deletePrebuilder) (string, error)
- func (a *PgsqlAdapter) ComplexSelect(prebuilder *selectPrebuilder) (string, error)
- func (a *PgsqlAdapter) CreateTable(name, table, charset, collation string, cols []DBTableColumn, ...) (string, error)
- func (a *PgsqlAdapter) DbVersion() string
- func (a *PgsqlAdapter) DropColumn(name, table, colName string) (string, error)
- func (a *PgsqlAdapter) DropTable(name, table string) (string, error)
- func (a *PgsqlAdapter) GetName() string
- func (a *PgsqlAdapter) GetStmt(name string) DBStmt
- func (a *PgsqlAdapter) GetStmts() map[string]DBStmt
- func (a *PgsqlAdapter) Purge(name, table string) (string, error)
- func (a *PgsqlAdapter) RemoveIndex(name, table, iname string) (string, error)
- func (a *PgsqlAdapter) RenameColumn(name, table, oldName, newName string) (string, error)
- func (a *PgsqlAdapter) SetDefaultColumn(name, table, colName, colType, defaultStr string) (string, error)
- func (a *PgsqlAdapter) SimpleBulkInsert(name, table, columns string, fieldSet []string) (string, error)
- func (a *PgsqlAdapter) SimpleCount(name, table, where, limit string) (string, error)
- func (a *PgsqlAdapter) SimpleDelete(name, table, where string) (string, error)
- func (a *PgsqlAdapter) SimpleInnerJoin(name, table1, table2, columns, joiners, where, orderby, limit string) (string, error)
- func (a *PgsqlAdapter) SimpleInsert(name, table, columns, fields string) (string, error)
- func (a *PgsqlAdapter) SimpleInsertInnerJoin(name string, ins DBInsert, sel DBJoin) (string, error)
- func (a *PgsqlAdapter) SimpleInsertLeftJoin(name string, ins DBInsert, sel DBJoin) (string, error)
- func (a *PgsqlAdapter) SimpleInsertSelect(name string, ins DBInsert, sel DBSelect) (string, error)
- func (a *PgsqlAdapter) SimpleLeftJoin(name, table1, table2, columns, joiners, where, orderby, limit string) (string, error)
- func (a *PgsqlAdapter) SimpleReplace(name, table, columns, fields string) (string, error)
- func (a *PgsqlAdapter) SimpleSelect(name, table, columns, where, orderby, limit string) (string, error)
- func (a *PgsqlAdapter) SimpleUpdate(up *updatePrebuilder) (string, error)
- func (a *PgsqlAdapter) SimpleUpdateSelect(up *updatePrebuilder) (string, error)
- func (a *PgsqlAdapter) SimpleUpsert(name, table, columns, fields, where string) (string, error)
- func (a *PgsqlAdapter) Write() error
- type QueryPlugin
- type SetPrimaryKeys
- type SimpleModel
- type TransactionBuilder
- func (b *TransactionBuilder) QuickDelete(table string, where string) *transactionStmt
- func (b *TransactionBuilder) QuickInsert(table string, where string) *transactionStmt
- func (b *TransactionBuilder) SimpleDelete(table string, where string) (stmt *sql.Stmt, err error)
- func (b *TransactionBuilder) SimpleInsert(table string, columns string, fields string) (stmt *sql.Stmt, err error)
Constants ¶
const ( IdenFunc = iota IdenColumn IdenString IdenLiteral )
const ( TokenFunc = iota TokenOp TokenColumn TokenNumber TokenString TokenSub TokenOr TokenNot TokenLike TokenScope )
const FlexiHint1 = len(` <UTC_TIMESTAMP()-interval ? `)
The new version of buildWhere() currently only used in ComplexSelect for complex OO builder queries
Variables ¶
var Builder *builder
var ErrNoAdapter = errors.New("This adapter doesn't exist")
var ErrNoCollation = errors.New("You didn't provide a collation")
var Install *installer
var LogPrepares = true
var Registry []Adapter
Functions ¶
func InterfaceMapToInsertStrings ¶
TODO: Test this
Types ¶
type AccBuilder ¶
type AccRowWrap ¶
type AccRowWrap struct {
// contains filtered or unexported fields
}
func (*AccRowWrap) Scan ¶
func (w *AccRowWrap) Scan(dest ...interface{}) error
type AccSelectBuilder ¶
type AccSelectBuilder struct {
// contains filtered or unexported fields
}
func (*AccSelectBuilder) Cols ¶
func (b *AccSelectBuilder) Cols(cols string) *AccSelectBuilder
func (*AccSelectBuilder) Columns ¶
func (b *AccSelectBuilder) Columns(cols string) *AccSelectBuilder
func (*AccSelectBuilder) ComplexPrepare ¶
func (b *AccSelectBuilder) ComplexPrepare() *sql.Stmt
func (*AccSelectBuilder) DateCutoff ¶
func (b *AccSelectBuilder) DateCutoff(col string, quantity int, unit string) *AccSelectBuilder
func (*AccSelectBuilder) DateOlderThanQ ¶
func (b *AccSelectBuilder) DateOlderThanQ(col, unit string) *AccSelectBuilder
func (*AccSelectBuilder) Each ¶
func (b *AccSelectBuilder) Each(h func(*sql.Rows) error) error
Experimental, reduces lines
func (*AccSelectBuilder) EachP ¶
func (b *AccSelectBuilder) EachP(h func(*sql.Rows) error, p ...interface{}) error
func (*AccSelectBuilder) In ¶
func (b *AccSelectBuilder) In(col string, inList []int) *AccSelectBuilder
TODO: Don't implement the SQL at the accumulator level but the adapter level
func (*AccSelectBuilder) InPQuery ¶
TODO: Don't implement the SQL at the accumulator level but the adapter level
func (*AccSelectBuilder) InQ ¶
func (b *AccSelectBuilder) InQ(col string, sb *AccSelectBuilder) *AccSelectBuilder
func (*AccSelectBuilder) Limit ¶
func (b *AccSelectBuilder) Limit(limit string) *AccSelectBuilder
func (*AccSelectBuilder) Orderby ¶
func (b *AccSelectBuilder) Orderby(orderby string) *AccSelectBuilder
func (*AccSelectBuilder) Prepare ¶
func (b *AccSelectBuilder) Prepare() *sql.Stmt
func (*AccSelectBuilder) Query ¶
func (b *AccSelectBuilder) Query(args ...interface{}) (*sql.Rows, error)
func (*AccSelectBuilder) QueryRow ¶
func (b *AccSelectBuilder) QueryRow(args ...interface{}) *AccRowWrap
TODO: Test to make sure the errors are passed up properly
func (*AccSelectBuilder) Stmt ¶
func (b *AccSelectBuilder) Stmt() *sql.Stmt
func (*AccSelectBuilder) Where ¶
func (b *AccSelectBuilder) Where(where string) *AccSelectBuilder
type Accumulator ¶
type Accumulator struct {
// contains filtered or unexported fields
}
func NewAcc ¶
func NewAcc() *Accumulator
So we don't have to do the qgen.Builder.Accumulator() boilerplate all the time
func (*Accumulator) BulkInsert ¶
func (acc *Accumulator) BulkInsert(table string) *accBulkInsertBuilder
func (*Accumulator) Count ¶
func (acc *Accumulator) Count(table string) *accCountBuilder
func (*Accumulator) CreateTable ¶
func (acc *Accumulator) CreateTable(table, charset, collation string, columns []DBTableColumn, keys []DBTableKey) *sql.Stmt
func (*Accumulator) CreateTableTx ¶
func (acc *Accumulator) CreateTableTx(tx *sql.Tx, table, charset, collation string, columns []DBTableColumn, keys []DBTableKey) (stmt *sql.Stmt)
func (*Accumulator) Delete ¶
func (acc *Accumulator) Delete(table string) *accDeleteBuilder
func (*Accumulator) Exists ¶
func (acc *Accumulator) Exists(tbl, col string) *AccSelectBuilder
func (*Accumulator) FirstError ¶
func (acc *Accumulator) FirstError() error
func (*Accumulator) GetAdapter ¶
func (acc *Accumulator) GetAdapter() Adapter
func (*Accumulator) Insert ¶
func (acc *Accumulator) Insert(table string) *accInsertBuilder
func (*Accumulator) Model ¶
func (acc *Accumulator) Model(table string) *accModelBuilder
func (*Accumulator) Purge ¶
func (acc *Accumulator) Purge(table string) *sql.Stmt
I don't know why you need this, but here it is x.x
func (*Accumulator) RawPrepare ¶
func (acc *Accumulator) RawPrepare(res string) *sql.Stmt
func (*Accumulator) RecordError ¶
func (acc *Accumulator) RecordError(err error)
func (*Accumulator) Select ¶
func (acc *Accumulator) Select(table string) *AccSelectBuilder
func (*Accumulator) SetAdapter ¶
func (acc *Accumulator) SetAdapter(name string) error
func (*Accumulator) SetConn ¶
func (acc *Accumulator) SetConn(conn *sql.DB)
func (*Accumulator) SimpleBulkInsert ¶
func (acc *Accumulator) SimpleBulkInsert(table, cols string, fieldSet []string) *sql.Stmt
func (*Accumulator) SimpleCount ¶
func (acc *Accumulator) SimpleCount(table, where, limit string) *sql.Stmt
func (*Accumulator) SimpleCountTx ¶
func (*Accumulator) SimpleDelete ¶
func (acc *Accumulator) SimpleDelete(table, where string) *sql.Stmt
func (*Accumulator) SimpleDeleteTx ¶
func (*Accumulator) SimpleInnerJoin ¶
func (acc *Accumulator) SimpleInnerJoin(table1, table2, columns, joiners, where, orderby, limit string) *sql.Stmt
func (*Accumulator) SimpleInnerJoinTx ¶
func (*Accumulator) SimpleInsert ¶
func (acc *Accumulator) SimpleInsert(table, columns, fields string) *sql.Stmt
func (*Accumulator) SimpleInsertInnerJoin ¶
func (acc *Accumulator) SimpleInsertInnerJoin(ins DBInsert, sel DBJoin) *sql.Stmt
func (*Accumulator) SimpleInsertInnerJoinTx ¶
func (*Accumulator) SimpleInsertLeftJoin ¶
func (acc *Accumulator) SimpleInsertLeftJoin(ins DBInsert, sel DBJoin) *sql.Stmt
func (*Accumulator) SimpleInsertLeftJoinTx ¶
func (*Accumulator) SimpleInsertSelect ¶
func (acc *Accumulator) SimpleInsertSelect(ins DBInsert, sel DBSelect) *sql.Stmt
func (*Accumulator) SimpleInsertSelectTx ¶
func (*Accumulator) SimpleInsertTx ¶
func (*Accumulator) SimpleLeftJoin ¶
func (acc *Accumulator) SimpleLeftJoin(table1, table2, columns, joiners, where, orderby, limit string) *sql.Stmt
func (*Accumulator) SimpleLeftJoinTx ¶
func (*Accumulator) SimpleModel ¶
func (acc *Accumulator) SimpleModel(tbl, colstr, primary string) SimpleModel
func (*Accumulator) SimpleSelect ¶
func (acc *Accumulator) SimpleSelect(table, columns, where, orderby, limit string) *sql.Stmt
func (*Accumulator) SimpleSelectTx ¶
func (acc *Accumulator) SimpleSelectTx(tx *sql.Tx, table, columns, where, orderby, limit string) (stmt *sql.Stmt)
These ones support transactions
func (*Accumulator) SimpleUpdate ¶
func (acc *Accumulator) SimpleUpdate(table, set, where string) *sql.Stmt
func (*Accumulator) SimpleUpdateSelect ¶
func (acc *Accumulator) SimpleUpdateSelect(table, set, table2, cols, where, orderby, limit string) *sql.Stmt
func (*Accumulator) SimpleUpdateTx ¶
func (*Accumulator) Tx ¶
func (acc *Accumulator) Tx(handler func(*TransactionBuilder) error)
func (*Accumulator) Update ¶
func (acc *Accumulator) Update(table string) *accUpdateBuilder
type Adapter ¶
type Adapter interface { GetName() string BuildConn(config map[string]string) (*sql.DB, error) DbVersion() string DropTable(name, table string) (string, error) CreateTable(name, table, charset, collation string, cols []DBTableColumn, keys []DBTableKey) (string, error) // TODO: Some way to add indices and keys // TODO: Test this AddColumn(name, table string, col DBTableColumn, key *DBTableKey) (string, error) DropColumn(name, table, colName string) (string, error) RenameColumn(name, table, oldName, newName string) (string, error) ChangeColumn(name, table, colName string, col DBTableColumn) (string, error) SetDefaultColumn(name, table, colName, colType, defaultStr string) (string, error) AddIndex(name, table, iname, colname string) (string, error) AddKey(name, table, col string, key DBTableKey) (string, error) RemoveIndex(name, table, col string) (string, error) AddForeignKey(name, table, col, ftable, fcol string, cascade bool) (out string, e error) SimpleInsert(name, table, cols, fields string) (string, error) SimpleBulkInsert(name, table, cols string, fieldSet []string) (string, error) SimpleUpdate(b *updatePrebuilder) (string, error) SimpleUpdateSelect(b *updatePrebuilder) (string, error) // ! Experimental SimpleDelete(name, table, where string) (string, error) Purge(name, table string) (string, error) SimpleSelect(name, table, cols, where, orderby, limit string) (string, error) ComplexDelete(b *deletePrebuilder) (string, error) SimpleLeftJoin(name, table1, table2, cols, joiners, where, orderby, limit string) (string, error) SimpleInnerJoin(string, string, string, string, string, string, string, string) (string, error) SimpleInsertSelect(string, DBInsert, DBSelect) (string, error) SimpleInsertLeftJoin(string, DBInsert, DBJoin) (string, error) SimpleInsertInnerJoin(string, DBInsert, DBJoin) (string, error) SimpleCount(string, string, string, string) (string, error) ComplexSelect(*selectPrebuilder) (string, error) Builder() *prebuilder Write() error }
TODO: Add the TableExists and ColumnExists methods
func GetAdapter ¶
type DBInstallInstruction ¶
type DBInstallTable ¶
type DBInstallTable struct { Name string Charset string Collation string Columns []DBTableColumn Keys []DBTableKey }
TODO: Add methods to this to construct it OO-like
type DBTableColumn ¶
type DBTableKey ¶
type DBWhere ¶
type DBWhere struct {
Expr []DBToken // Simple expressions, the innards of functions are opaque for now.
}
type MssqlAdapter ¶
type MssqlAdapter struct { Name string // ? - Do we really need this? Can't we hard-code this? Buffer map[string]DBStmt BufferOrder []string // Map iteration order is random, so we need this to track the order, so we don't get huge diffs every commit // contains filtered or unexported fields }
func (*MssqlAdapter) AddColumn ¶
func (a *MssqlAdapter) AddColumn(name, table string, column DBTableColumn, key *DBTableKey) (string, error)
TODO: Test this, not sure if some things work TODO: Add support for keys
func (*MssqlAdapter) AddForeignKey ¶
func (a *MssqlAdapter) AddForeignKey(name, table, column, ftable, fcolumn string, cascade bool) (out string, e error)
TODO: Implement this TODO: Test to make sure everything works here
func (*MssqlAdapter) AddIndex ¶
func (a *MssqlAdapter) AddIndex(name, table, iname, colname string) (string, error)
TODO: Implement this TODO: Test to make sure everything works here
func (*MssqlAdapter) AddKey ¶
func (a *MssqlAdapter) AddKey(name, table, column string, key DBTableKey) (string, error)
TODO: Implement this TODO: Test to make sure everything works here
func (*MssqlAdapter) Builder ¶
func (a *MssqlAdapter) Builder() *prebuilder
func (*MssqlAdapter) ChangeColumn ¶
func (a *MssqlAdapter) ChangeColumn(name, table, colName string, col DBTableColumn) (string, error)
TODO: Implement this
func (*MssqlAdapter) ComplexDelete ¶
func (a *MssqlAdapter) ComplexDelete(b *deletePrebuilder) (string, error)
func (*MssqlAdapter) ComplexSelect ¶
func (a *MssqlAdapter) ComplexSelect(preBuilder *selectPrebuilder) (string, error)
TODO: ComplexSelect
func (*MssqlAdapter) CreateTable ¶
func (a *MssqlAdapter) CreateTable(name, table, charset, collation string, columns []DBTableColumn, keys []DBTableKey) (string, error)
TODO: Add support for foreign keys? TODO: Convert any remaining stringy types to nvarchar We may need to change the CreateTable API to better suit Mssql and the other database drivers which are coming up
func (*MssqlAdapter) DbVersion ¶
func (a *MssqlAdapter) DbVersion() string
func (*MssqlAdapter) DropColumn ¶
func (a *MssqlAdapter) DropColumn(name, table, colName string) (string, error)
TODO: Implement this
func (*MssqlAdapter) DropTable ¶
func (a *MssqlAdapter) DropTable(name, table string) (string, error)
func (*MssqlAdapter) GetName ¶
func (a *MssqlAdapter) GetName() string
GetName gives you the name of the database adapter. In this case, it's Mssql
func (*MssqlAdapter) GetStmt ¶
func (a *MssqlAdapter) GetStmt(name string) DBStmt
func (*MssqlAdapter) GetStmts ¶
func (a *MssqlAdapter) GetStmts() map[string]DBStmt
func (*MssqlAdapter) Purge ¶
func (a *MssqlAdapter) Purge(name string, table string) (string, error)
We don't want to accidentally wipe tables, so we'll have a separate method for purging tables instead
func (*MssqlAdapter) RemoveIndex ¶
func (a *MssqlAdapter) RemoveIndex(name, table, iname string) (string, error)
TODO: Implement this TODO: Test to make sure everything works here
func (*MssqlAdapter) RenameColumn ¶
func (a *MssqlAdapter) RenameColumn(name, table, oldName, newName string) (string, error)
TODO: Implement this
func (*MssqlAdapter) SetDefaultColumn ¶
func (a *MssqlAdapter) SetDefaultColumn(name, table, colName, colType, defaultStr string) (string, error)
TODO: Implement this
func (*MssqlAdapter) SetPrimaryKeys ¶
func (a *MssqlAdapter) SetPrimaryKeys(keys map[string]string)
func (*MssqlAdapter) SimpleBulkInsert ¶
func (a *MssqlAdapter) SimpleBulkInsert(name, table, cols string, fieldSet []string) (string, error)
func (*MssqlAdapter) SimpleCount ¶
func (a *MssqlAdapter) SimpleCount(name, table, where, limit string) (string, error)
func (*MssqlAdapter) SimpleDelete ¶
func (*MssqlAdapter) SimpleInnerJoin ¶
func (*MssqlAdapter) SimpleInsert ¶
func (a *MssqlAdapter) SimpleInsert(name, table, cols, fields string) (string, error)
func (*MssqlAdapter) SimpleInsertInnerJoin ¶
func (*MssqlAdapter) SimpleInsertLeftJoin ¶
func (*MssqlAdapter) SimpleInsertSelect ¶
func (*MssqlAdapter) SimpleLeftJoin ¶
func (*MssqlAdapter) SimpleReplace ¶
func (a *MssqlAdapter) SimpleReplace(name, table, columns, fields string) (string, error)
! DEPRECATED
func (*MssqlAdapter) SimpleSelect ¶
func (*MssqlAdapter) SimpleUpdate ¶
func (a *MssqlAdapter) SimpleUpdate(up *updatePrebuilder) (string, error)
func (*MssqlAdapter) SimpleUpdateSelect ¶
func (a *MssqlAdapter) SimpleUpdateSelect(b *updatePrebuilder) (string, error)
func (*MssqlAdapter) SimpleUpsert ¶
func (a *MssqlAdapter) SimpleUpsert(name, table, columns, fields, where string) (string, error)
func (*MssqlAdapter) Write ¶
func (a *MssqlAdapter) Write() error
type MySQLUpsertCallback ¶
type MySQLUpsertCallback struct {
// contains filtered or unexported fields
}
func PrepareMySQLUpsertCallback ¶
func PrepareMySQLUpsertCallback(db *sql.DB, query string) (*MySQLUpsertCallback, error)
type MysqlAdapter ¶
type MysqlAdapter struct { Name string // ? - Do we really need this? Can't we hard-code this? Buffer map[string]DBStmt BufferOrder []string // Map iteration order is random, so we need this to track the order, so we don't get huge diffs every commit }
func (*MysqlAdapter) AddColumn ¶
func (a *MysqlAdapter) AddColumn(name, table string, col DBTableColumn, key *DBTableKey) (string, error)
TODO: Support AFTER column TODO: Test to make sure everything works here
func (*MysqlAdapter) AddForeignKey ¶
func (a *MysqlAdapter) AddForeignKey(name, table, col, ftable, fcolumn string, cascade bool) (out string, e error)
func (*MysqlAdapter) AddIndex ¶
func (a *MysqlAdapter) AddIndex(name, table, iname, colname string) (string, error)
TODO: Test to make sure everything works here
func (*MysqlAdapter) AddKey ¶
func (a *MysqlAdapter) AddKey(name, table, cols string, key DBTableKey) (string, error)
TODO: Test to make sure everything works here Only supports FULLTEXT right now
func (*MysqlAdapter) Builder ¶
func (a *MysqlAdapter) Builder() *prebuilder
func (*MysqlAdapter) ChangeColumn ¶
func (a *MysqlAdapter) ChangeColumn(name, table, colName string, col DBTableColumn) (string, error)
func (*MysqlAdapter) ComplexDelete ¶
func (a *MysqlAdapter) ComplexDelete(b *deletePrebuilder) (string, error)
func (*MysqlAdapter) ComplexSelect ¶
func (a *MysqlAdapter) ComplexSelect(preBuilder *selectPrebuilder) (out string, e error)
func (*MysqlAdapter) CreateTable ¶
func (a *MysqlAdapter) CreateTable(name, table, charset, collation string, cols []DBTableColumn, keys []DBTableKey) (string, error)
func (*MysqlAdapter) DbVersion ¶
func (a *MysqlAdapter) DbVersion() string
func (*MysqlAdapter) DropColumn ¶
func (a *MysqlAdapter) DropColumn(name, table, colName string) (string, error)
func (*MysqlAdapter) DropTable ¶
func (a *MysqlAdapter) DropTable(name, table string) (string, error)
func (*MysqlAdapter) GetName ¶
func (a *MysqlAdapter) GetName() string
GetName gives you the name of the database adapter. In this case, it's mysql
func (*MysqlAdapter) GetStmt ¶
func (a *MysqlAdapter) GetStmt(name string) DBStmt
func (*MysqlAdapter) GetStmts ¶
func (a *MysqlAdapter) GetStmts() map[string]DBStmt
func (*MysqlAdapter) Purge ¶
func (a *MysqlAdapter) Purge(name, table string) (string, error)
We don't want to accidentally wipe tables, so we'll have a separate method for purging tables instead
func (*MysqlAdapter) RemoveIndex ¶
func (a *MysqlAdapter) RemoveIndex(name, table, iname string) (string, error)
func (*MysqlAdapter) RenameColumn ¶
func (a *MysqlAdapter) RenameColumn(name, table, oldName, newName string) (string, error)
! Currently broken in MariaDB. Planned.
func (*MysqlAdapter) SetDefaultColumn ¶
func (a *MysqlAdapter) SetDefaultColumn(name, table, colName, colType, defaultStr string) (string, error)
func (*MysqlAdapter) SimpleBulkInsert ¶
func (a *MysqlAdapter) SimpleBulkInsert(name, table, cols string, fieldSet []string) (string, error)
func (*MysqlAdapter) SimpleCount ¶
func (a *MysqlAdapter) SimpleCount(name, table, where, limit string) (q string, e error)
func (*MysqlAdapter) SimpleDelete ¶
func (a *MysqlAdapter) SimpleDelete(name, table, where string) (string, error)
func (*MysqlAdapter) SimpleInnerJoin ¶
func (a *MysqlAdapter) SimpleInnerJoin(name, table1, table2, columns, joiners, where, orderby, limit string) (string, error)
func (*MysqlAdapter) SimpleInsert ¶
func (a *MysqlAdapter) SimpleInsert(name, table, cols, fields string) (string, error)
func (*MysqlAdapter) SimpleInsertInnerJoin ¶
func (*MysqlAdapter) SimpleInsertLeftJoin ¶
func (*MysqlAdapter) SimpleInsertSelect ¶
func (*MysqlAdapter) SimpleLeftJoin ¶
func (a *MysqlAdapter) SimpleLeftJoin(name, table1, table2, columns, joiners, where, orderby, limit string) (string, error)
func (*MysqlAdapter) SimpleReplace ¶
func (a *MysqlAdapter) SimpleReplace(name, table, cols, fields string) (string, error)
! DEPRECATED
func (*MysqlAdapter) SimpleSelect ¶
func (a *MysqlAdapter) SimpleSelect(name, table, cols, where, orderby, limit string) (string, error)
func (*MysqlAdapter) SimpleUpdate ¶
func (a *MysqlAdapter) SimpleUpdate(up *updatePrebuilder) (string, error)
func (*MysqlAdapter) SimpleUpdateSelect ¶
func (a *MysqlAdapter) SimpleUpdateSelect(up *updatePrebuilder) (string, error)
func (*MysqlAdapter) SimpleUpsert ¶
func (a *MysqlAdapter) SimpleUpsert(name, table, columns, fields, where string) (string, error)
func (*MysqlAdapter) Write ¶
func (a *MysqlAdapter) Write() error
type PgsqlAdapter ¶
type PgsqlAdapter struct { Name string // ? - Do we really need this? Can't we hard-code this? Buffer map[string]DBStmt BufferOrder []string // Map iteration order is random, so we need this to track the order, so we don't get huge diffs every commit }
func (*PgsqlAdapter) AddColumn ¶
func (a *PgsqlAdapter) AddColumn(name, table string, column DBTableColumn, key *DBTableKey) (string, error)
TODO: Implement this
func (*PgsqlAdapter) AddForeignKey ¶
func (a *PgsqlAdapter) AddForeignKey(name, table, column, ftable, fcolumn string, cascade bool) (out string, e error)
TODO: Implement this TODO: Test to make sure everything works here
func (*PgsqlAdapter) AddIndex ¶
func (a *PgsqlAdapter) AddIndex(name, table, iname, colname string) (string, error)
TODO: Implement this TODO: Test to make sure everything works here
func (*PgsqlAdapter) AddKey ¶
func (a *PgsqlAdapter) AddKey(name, table, column string, key DBTableKey) (string, error)
TODO: Implement this TODO: Test to make sure everything works here
func (*PgsqlAdapter) Builder ¶
func (a *PgsqlAdapter) Builder() *prebuilder
func (*PgsqlAdapter) ChangeColumn ¶
func (a *PgsqlAdapter) ChangeColumn(name, table, colName string, col DBTableColumn) (string, error)
TODO: Implement this
func (*PgsqlAdapter) ComplexDelete ¶
func (a *PgsqlAdapter) ComplexDelete(b *deletePrebuilder) (string, error)
TODO: Implement this
func (*PgsqlAdapter) ComplexSelect ¶
func (a *PgsqlAdapter) ComplexSelect(prebuilder *selectPrebuilder) (string, error)
TODO: Implement this
func (*PgsqlAdapter) CreateTable ¶
func (a *PgsqlAdapter) CreateTable(name, table, charset, collation string, cols []DBTableColumn, keys []DBTableKey) (string, error)
TODO: Implement this We may need to change the CreateTable API to better suit PGSQL and the other database drivers which are coming up
func (*PgsqlAdapter) DbVersion ¶
func (a *PgsqlAdapter) DbVersion() string
func (*PgsqlAdapter) DropColumn ¶
func (a *PgsqlAdapter) DropColumn(name, table, colName string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) DropTable ¶
func (a *PgsqlAdapter) DropTable(name, table string) (string, error)
func (*PgsqlAdapter) GetName ¶
func (a *PgsqlAdapter) GetName() string
GetName gives you the name of the database adapter. In this case, it's pgsql
func (*PgsqlAdapter) GetStmt ¶
func (a *PgsqlAdapter) GetStmt(name string) DBStmt
func (*PgsqlAdapter) GetStmts ¶
func (a *PgsqlAdapter) GetStmts() map[string]DBStmt
func (*PgsqlAdapter) Purge ¶
func (a *PgsqlAdapter) Purge(name, table string) (string, error)
TODO: Implement this We don't want to accidentally wipe tables, so we'll have a separate method for purging tables instead
func (*PgsqlAdapter) RemoveIndex ¶
func (a *PgsqlAdapter) RemoveIndex(name, table, iname string) (string, error)
TODO: Implement this TODO: Test to make sure everything works here
func (*PgsqlAdapter) RenameColumn ¶
func (a *PgsqlAdapter) RenameColumn(name, table, oldName, newName string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SetDefaultColumn ¶
func (a *PgsqlAdapter) SetDefaultColumn(name, table, colName, colType, defaultStr string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleBulkInsert ¶
func (a *PgsqlAdapter) SimpleBulkInsert(name, table, columns string, fieldSet []string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleCount ¶
func (a *PgsqlAdapter) SimpleCount(name, table, where, limit string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleDelete ¶
func (a *PgsqlAdapter) SimpleDelete(name, table, where string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleInnerJoin ¶
func (a *PgsqlAdapter) SimpleInnerJoin(name, table1, table2, columns, joiners, where, orderby, limit string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleInsert ¶
func (a *PgsqlAdapter) SimpleInsert(name, table, columns, fields string) (string, error)
TODO: Test this ! We need to get the last ID out of this somehow, maybe add returning to every query? Might require some sort of wrapper over the sql statements
func (*PgsqlAdapter) SimpleInsertInnerJoin ¶
TODO: Implement this
func (*PgsqlAdapter) SimpleInsertLeftJoin ¶
TODO: Implement this
func (*PgsqlAdapter) SimpleInsertSelect ¶
TODO: Implement this
func (*PgsqlAdapter) SimpleLeftJoin ¶
func (a *PgsqlAdapter) SimpleLeftJoin(name, table1, table2, columns, joiners, where, orderby, limit string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleReplace ¶
func (a *PgsqlAdapter) SimpleReplace(name, table, columns, fields string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleSelect ¶
func (a *PgsqlAdapter) SimpleSelect(name, table, columns, where, orderby, limit string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleUpdate ¶
func (a *PgsqlAdapter) SimpleUpdate(up *updatePrebuilder) (string, error)
TODO: Implemented, but we need CreateTable and a better installer to *test* it
func (*PgsqlAdapter) SimpleUpdateSelect ¶
func (a *PgsqlAdapter) SimpleUpdateSelect(up *updatePrebuilder) (string, error)
TODO: Implement this
func (*PgsqlAdapter) SimpleUpsert ¶
func (a *PgsqlAdapter) SimpleUpsert(name, table, columns, fields, where string) (string, error)
TODO: Implement this
func (*PgsqlAdapter) Write ¶
func (a *PgsqlAdapter) Write() error
type QueryPlugin ¶
type SetPrimaryKeys ¶
type SimpleModel ¶
type SimpleModel struct {
// contains filtered or unexported fields
}
func (SimpleModel) Create ¶
func (m SimpleModel) Create(args ...interface{}) error
func (SimpleModel) CreateID ¶
func (m SimpleModel) CreateID(args ...interface{}) (int, error)
func (SimpleModel) Delete ¶
func (m SimpleModel) Delete(keyVal interface{}) error
func (SimpleModel) Update ¶
func (m SimpleModel) Update(args ...interface{}) error
type TransactionBuilder ¶
type TransactionBuilder struct {
// contains filtered or unexported fields
}
func (*TransactionBuilder) QuickDelete ¶
func (b *TransactionBuilder) QuickDelete(table string, where string) *transactionStmt
Quick* versions refer to it being quick to type not the performance. For performance critical transactions, you might want to use the Simple* methods or the *Tx methods on the main builder. Alternate suggestions for names are welcome :)
func (*TransactionBuilder) QuickInsert ¶
func (b *TransactionBuilder) QuickInsert(table string, where string) *transactionStmt