qgen

package
v0.0.0-...-553e66b Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

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

View Source
const (
	IdenFunc = iota
	IdenColumn
	IdenString
	IdenLiteral
)
View Source
const (
	TokenFunc = iota
	TokenOp
	TokenColumn
	TokenNumber
	TokenString
	TokenSub
	TokenOr
	TokenNot
	TokenLike
	TokenScope
)
View Source
const FlexiHint1 = len(` <UTC_TIMESTAMP()-interval ?  `)

The new version of buildWhere() currently only used in ComplexSelect for complex OO builder queries

Variables

View Source
var Builder *builder
View Source
var ErrNoAdapter = errors.New("This adapter doesn't exist")
View Source
var ErrNoCollation = errors.New("You didn't provide a collation")
View Source
var Install *installer
View Source
var LogPrepares = true
View Source
var Registry []Adapter

Functions

func InterfaceMapToInsertStrings

func InterfaceMapToInsertStrings(data map[string]interface{}, order string) (cols, values string)

TODO: Test this

Types

type AccBuilder

type AccBuilder interface {
	Prepare() *sql.Stmt
}

type AccExec

type AccExec interface {
	Exec(args ...interface{}) (res sql.Result, err error)
}

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) EachInt

func (b *AccSelectBuilder) EachInt(h func(int) error) error

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

func (b *AccSelectBuilder) InPQuery(col string, inList []int) (*sql.Rows, error)

TODO: Don't implement the SQL at the accumulator level but the adapter level

func (*AccSelectBuilder) InQ

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) PurgeTx

func (acc *Accumulator) PurgeTx(tx *sql.Tx, table string) (stmt *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 (acc *Accumulator) SimpleCountTx(tx *sql.Tx, table, where, limit string) (stmt *sql.Stmt)

func (*Accumulator) SimpleDelete

func (acc *Accumulator) SimpleDelete(table, where string) *sql.Stmt

func (*Accumulator) SimpleDeleteTx

func (acc *Accumulator) SimpleDeleteTx(tx *sql.Tx, table, where string) (stmt *sql.Stmt)

func (*Accumulator) SimpleInnerJoin

func (acc *Accumulator) SimpleInnerJoin(table1, table2, columns, joiners, where, orderby, limit string) *sql.Stmt

func (*Accumulator) SimpleInnerJoinTx

func (acc *Accumulator) SimpleInnerJoinTx(tx *sql.Tx, table1, table2, columns, joiners, where, orderby, limit string) (stmt *sql.Stmt)

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 (acc *Accumulator) SimpleInsertInnerJoinTx(tx *sql.Tx, ins DBInsert, sel DBJoin) (stmt *sql.Stmt)

func (*Accumulator) SimpleInsertLeftJoin

func (acc *Accumulator) SimpleInsertLeftJoin(ins DBInsert, sel DBJoin) *sql.Stmt

func (*Accumulator) SimpleInsertLeftJoinTx

func (acc *Accumulator) SimpleInsertLeftJoinTx(tx *sql.Tx, ins DBInsert, sel DBJoin) (stmt *sql.Stmt)

func (*Accumulator) SimpleInsertSelect

func (acc *Accumulator) SimpleInsertSelect(ins DBInsert, sel DBSelect) *sql.Stmt

func (*Accumulator) SimpleInsertSelectTx

func (acc *Accumulator) SimpleInsertSelectTx(tx *sql.Tx, ins DBInsert, sel DBSelect) (stmt *sql.Stmt)

func (*Accumulator) SimpleInsertTx

func (acc *Accumulator) SimpleInsertTx(tx *sql.Tx, table, columns, fields string) (stmt *sql.Stmt)

func (*Accumulator) SimpleLeftJoin

func (acc *Accumulator) SimpleLeftJoin(table1, table2, columns, joiners, where, orderby, limit string) *sql.Stmt

func (*Accumulator) SimpleLeftJoinTx

func (acc *Accumulator) SimpleLeftJoinTx(tx *sql.Tx, table1, table2, columns, joiners, where, orderby, limit string) (stmt *sql.Stmt)

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 (acc *Accumulator) SimpleUpdateTx(tx *sql.Tx, table, set, where string) (stmt *sql.Stmt)

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

func GetAdapter(name string) (adap Adapter, err error)

type DBColumn

type DBColumn struct {
	Table string
	Left  string // Could be a function or a column, so I'm naming this Left
	Alias string // aka AS Blah, if it's present
	//Type  string // function or column
	Type int
}

type DBField

type DBField struct {
	Name string
	//Type string
	Type int
}

type DBInsert

type DBInsert struct {
	Table   string
	Columns string
	Fields  string
}

type DBInstallInstruction

type DBInstallInstruction struct {
	Table    string
	Contents string
	Type     string
}

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 DBJoin

type DBJoin struct {
	Table1  string
	Table2  string
	Columns string
	Joiners string
	Where   string
	Orderby string
	Limit   string
}

type DBJoiner

type DBJoiner struct {
	LeftTable   string
	LeftColumn  string
	RightTable  string
	RightColumn string
	Operator    string
}

type DBLimit

type DBLimit struct {
	Offset   string // ? or int
	MaxCount string // ? or int
}

type DBOrder

type DBOrder struct {
	Column string
	Order  string
}

type DBSelect

type DBSelect struct {
	Table   string
	Columns string
	Where   string
	Orderby string
	Limit   string
}

type DBSetter

type DBSetter struct {
	Column string
	Expr   []DBToken // Simple expressions, the innards of functions are opaque for now.
}

type DBStmt

type DBStmt struct {
	Contents string
	Type     string // create-table, insert, update, delete
}

type DBTableColumn

type DBTableColumn struct {
	Name          string
	Type          string
	Size          int
	Null          bool
	AutoIncrement bool
	Default       string
}

type DBTableKey

type DBTableKey struct {
	Columns string
	Type    string

	// Foreign keys only
	FTable  string
	Cascade bool
}

type DBToken

type DBToken struct {
	Contents string
	//Type     string // function, op, column, number, string, sub, not, like
	Type int
}

type DBWhere

type DBWhere struct {
	Expr []DBToken // Simple expressions, the innards of functions are opaque for now.
}

type LitStr

type LitStr string

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) BuildConn

func (a *MssqlAdapter) BuildConn(config map[string]string) (*sql.DB, error)

TODO: Implement this

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 (a *MssqlAdapter) SimpleDelete(name string, table string, where string) (string, error)

func (*MssqlAdapter) SimpleInnerJoin

func (a *MssqlAdapter) SimpleInnerJoin(name string, table1 string, table2 string, columns string, joiners string, where string, orderby string, limit string) (string, error)

func (*MssqlAdapter) SimpleInsert

func (a *MssqlAdapter) SimpleInsert(name, table, cols, fields string) (string, error)

func (*MssqlAdapter) SimpleInsertInnerJoin

func (a *MssqlAdapter) SimpleInsertInnerJoin(name string, ins DBInsert, sel DBJoin) (string, error)

func (*MssqlAdapter) SimpleInsertLeftJoin

func (a *MssqlAdapter) SimpleInsertLeftJoin(name string, ins DBInsert, sel DBJoin) (string, error)

func (*MssqlAdapter) SimpleInsertSelect

func (a *MssqlAdapter) SimpleInsertSelect(name string, ins DBInsert, sel DBSelect) (string, error)

func (*MssqlAdapter) SimpleLeftJoin

func (a *MssqlAdapter) SimpleLeftJoin(name string, table1 string, table2 string, columns string, joiners string, where string, orderby string, limit string) (string, error)

func (*MssqlAdapter) SimpleReplace

func (a *MssqlAdapter) SimpleReplace(name, table, columns, fields string) (string, error)

! DEPRECATED

func (*MssqlAdapter) SimpleSelect

func (a *MssqlAdapter) SimpleSelect(name string, table string, columns string, where string, orderby string, limit string) (string, error)

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)

func (*MySQLUpsertCallback) Exec

func (double *MySQLUpsertCallback) Exec(args ...interface{}) (res sql.Result, err 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) BuildConn

func (a *MysqlAdapter) BuildConn(config map[string]string) (*sql.DB, error)

TODO: Add an option to disable unix pipes

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 (a *MysqlAdapter) SimpleInsertInnerJoin(name string, ins DBInsert, sel DBJoin) (string, error)

func (*MysqlAdapter) SimpleInsertLeftJoin

func (a *MysqlAdapter) SimpleInsertLeftJoin(name string, ins DBInsert, sel DBJoin) (string, error)

func (*MysqlAdapter) SimpleInsertSelect

func (a *MysqlAdapter) SimpleInsertSelect(name string, ins DBInsert, sel DBSelect) (string, error)

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) BuildConn

func (a *PgsqlAdapter) BuildConn(config map[string]string) (*sql.DB, error)

TODO: Implement this

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

func (a *PgsqlAdapter) SimpleInsertInnerJoin(name string, ins DBInsert, sel DBJoin) (string, error)

TODO: Implement this

func (*PgsqlAdapter) SimpleInsertLeftJoin

func (a *PgsqlAdapter) SimpleInsertLeftJoin(name string, ins DBInsert, sel DBJoin) (string, error)

TODO: Implement this

func (*PgsqlAdapter) SimpleInsertSelect

func (a *PgsqlAdapter) SimpleInsertSelect(name string, ins DBInsert, sel DBSelect) (string, error)

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 QueryPlugin interface {
	Hook(name string, args ...interface{}) error
	Write() error
}

type SetPrimaryKeys

type SetPrimaryKeys interface {
	SetPrimaryKeys(keys map[string]string)
}

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

func (*TransactionBuilder) SimpleDelete

func (b *TransactionBuilder) SimpleDelete(table string, where string) (stmt *sql.Stmt, err error)

func (*TransactionBuilder) SimpleInsert

func (b *TransactionBuilder) SimpleInsert(table string, columns string, fields string) (stmt *sql.Stmt, err error)

Jump to

Keyboard shortcuts

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