Versions in this module Expand all Collapse all v0 v0.4.4 Sep 9, 2015 Changes in this version + const BLOB_TYPE + const CacheExpired + const CacheGcInterval + const CacheGcMaxRemoved + const CacheMaxMemory + const IndexType + const MSSQL + const MYSQL + const NUMERIC_TYPE + const ONLYFROMDB + const ONLYTODB + const ORACLE + const POSTGRES + const SQLITE + const TEXT_TYPE + const TIME_TYPE + const TWOSIDES + const UNKNOW_TYPE + const UniqueType + var BigInt = "BIGINT" + var BigSerial = "BIGSERIAL" + var Binary = "BINARY" + var Bit = "BIT" + var Blob = "BLOB" + var Bool = "BOOL" + var BoolType = reflect.TypeOf(c_BOOL_DEFAULT) + var ByteType = reflect.TypeOf(c_BYTE_DEFAULT) + var Bytea = "BYTEA" + var Char = "CHAR" + var Clob = "CLOB" + var Complex128Type = reflect.TypeOf(c_COMPLEX128_DEFAULT) + var Complex64Type = reflect.TypeOf(c_COMPLEX64_DEFAULT) + var Date = "DATE" + var DateTime = "DATETIME" + var Decimal = "DECIMAL" + var Double = "DOUBLE" + var Enum = "ENUM" + var ErrCacheMiss = errors.New("xorm/cache: key not found.") + var ErrNoMapPointer = errors.New("mp should be a map's pointer") + var ErrNoStructPointer = errors.New("mp should be a struct's pointer") + var ErrNotStored = errors.New("xorm/cache: not stored.") + var Float = "FLOAT" + var Float32Type = reflect.TypeOf(c_FLOAT32_DEFAULT) + var Float64Type = reflect.TypeOf(c_FLOAT64_DEFAULT) + var Int = "INT" + var Int16Type = reflect.TypeOf(c_INT16_DEFAULT) + var Int32Type = reflect.TypeOf(c_INT32_DEFAULT) + var Int64Type = reflect.TypeOf(c_INT64_DEFAULT) + var Int8Type = reflect.TypeOf(c_INT8_DEFAULT) + var IntType = reflect.TypeOf(c_INT_DEFAULT) + var Integer = "INTEGER" + var Json = "JSON" + var LintGonicMapper = GonicMapper + var LongBlob = "LONGBLOB" + var LongText = "LONGTEXT" + var MediumBlob = "MEDIUMBLOB" + var MediumInt = "MEDIUMINT" + var MediumText = "MEDIUMTEXT" + var NVarchar = "NVARCHAR" + var Numeric = "NUMERIC" + var PtrBoolType = reflect.PtrTo(BoolType) + var PtrByteType = reflect.PtrTo(ByteType) + var PtrComplex128Type = reflect.PtrTo(Complex128Type) + var PtrComplex64Type = reflect.PtrTo(Complex64Type) + var PtrFloat32Type = reflect.PtrTo(Float32Type) + var PtrFloat64Type = reflect.PtrTo(Float64Type) + var PtrInt16Type = reflect.PtrTo(Int16Type) + var PtrInt32Type = reflect.PtrTo(Int32Type) + var PtrInt64Type = reflect.PtrTo(Int64Type) + var PtrInt8Type = reflect.PtrTo(Int8Type) + var PtrIntType = reflect.PtrTo(IntType) + var PtrStringType = reflect.PtrTo(StringType) + var PtrTimeType = reflect.PtrTo(TimeType) + var PtrUint16Type = reflect.PtrTo(Uint16Type) + var PtrUint32Type = reflect.PtrTo(Uint32Type) + var PtrUint64Type = reflect.PtrTo(Uint64Type) + var PtrUint8Type = reflect.PtrTo(Uint8Type) + var PtrUintType = reflect.PtrTo(UintType) + var Real = "REAL" + var Serial = "SERIAL" + var Set = "SET" + var SmallInt = "SMALLINT" + var SqlTypes = map[string]int + var StringType = reflect.TypeOf(c_EMPTY_STRING) + var Text = "TEXT" + var Time = "TIME" + var TimeStamp = "TIMESTAMP" + var TimeStampz = "TIMESTAMPZ" + var TimeType = reflect.TypeOf(c_TIME_DEFAULT) + var TinyBlob = "TINYBLOB" + var TinyInt = "TINYINT" + var TinyText = "TINYTEXT" + var Uint16Type = reflect.TypeOf(c_UINT16_DEFAULT) + var Uint32Type = reflect.TypeOf(c_UINT32_DEFAULT) + var Uint64Type = reflect.TypeOf(c_UINT64_DEFAULT) + var Uint8Type = reflect.TypeOf(c_UINT8_DEFAULT) + var UintType = reflect.TypeOf(c_UINT_DEFAULT) + var Uuid = "UUID" + var VarBinary = "VARBINARY" + var Varchar = "VARCHAR" + func GenSqlKey(sql string, args interface{}) string + func MapToSlice(query string, mp interface{}) (string, []interface{}, error) + func PutCacheSql(m Cacher, ids []PK, tableName, sql string, args interface{}) error + func ReflectNew(typ reflect.Type) reflect.Value + func RegisterDialect(dbName DbType, dialectFunc func() Dialect) + func RegisterDriver(driverName string, driver Driver) + func RegisteredDriverSize() int + func SQLType2Type(st SQLType) reflect.Type + func StructToSlice(query string, st interface{}) (string, []interface{}, error) + type Base struct + Logger ILogger + func (b *Base) AndStr() string + func (b *Base) CreateTableSql(table *Table, tableName, storeEngine, charset string) string + func (b *Base) DB() *DB + func (b *Base) DBType() DbType + func (b *Base) DataSourceName() string + func (b *Base) DriverName() string + func (b *Base) EqStr() string + func (b *Base) ForUpdateSql(query string) string + func (b *Base) FormatBytes(bs []byte) string + func (b *Base) Init(db *DB, dialect Dialect, uri *Uri, drivername, dataSourceName string) error + func (b *Base) OrStr() string + func (b *Base) SetLogger(logger ILogger) + func (b *Base) ShowCreateNull() bool + func (b *Base) URI() *Uri + func (db *Base) CreateIndexSql(tableName string, index *Index) string + func (db *Base) DropIndexSql(tableName string, index *Index) string + func (db *Base) DropTableSql(tableName string) string + func (db *Base) HasRecords(query string, args ...interface{}) (bool, error) + func (db *Base) IsColumnExist(tableName, colName string) (bool, error) + func (db *Base) ModifyColumnSql(tableName string, col *Column) string + func (db *Base) RollBackStr() string + func (db *Base) SupportDropIfExists() bool + type CacheMapper struct + func NewCacheMapper(mapper IMapper) *CacheMapper + func (m *CacheMapper) Obj2Table(o string) string + func (m *CacheMapper) Table2Obj(t string) string + type CacheStore interface + Del func(key string) error + Get func(key string) (interface{}, error) + Put func(key string, value interface{}) error + type Cacher interface + ClearBeans func(tableName string) + ClearIds func(tableName string) + DelBean func(tableName string, id string) + DelIds func(tableName, sql string) + GetBean func(tableName string, id string) interface{} + GetIds func(tableName, sql string) interface{} + PutBean func(tableName string, id string, obj interface{}) + PutIds func(tableName, sql string, ids interface{}) + type Column struct + Default string + DefaultIsEmpty bool + EnumOptions map[string]int + FieldName string + Indexes map[string]bool + IsAutoIncrement bool + IsCascade bool + IsCreated bool + IsDeleted bool + IsPrimaryKey bool + IsUpdated bool + IsVersion bool + Length int + Length2 int + MapType int + Name string + Nullable bool + SQLType SQLType + SetOptions map[string]int + func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column + func (col *Column) String(d Dialect) string + func (col *Column) StringNoPk(d Dialect) string + func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error) + func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error) + type Conversion interface + FromDB func([]byte) error + ToDB func() ([]byte, error) + type DB struct + Mapper IMapper + func FromDB(db *sql.DB) *DB + func Open(driverName, dataSourceName string) (*DB, error) + func OpenDialect(dialect Dialect) (*DB, error) + func (db *DB) Begin() (*Tx, error) + func (db *DB) ExecMap(query string, mp interface{}) (sql.Result, error) + func (db *DB) ExecStruct(query string, st interface{}) (sql.Result, error) + func (db *DB) Prepare(query string) (*Stmt, error) + func (db *DB) Query(query string, args ...interface{}) (*Rows, error) + func (db *DB) QueryMap(query string, mp interface{}) (*Rows, error) + func (db *DB) QueryRow(query string, args ...interface{}) *Row + func (db *DB) QueryRowMap(query string, mp interface{}) *Row + func (db *DB) QueryRowStruct(query string, st interface{}) *Row + func (db *DB) QueryStruct(query string, st interface{}) (*Rows, error) + type DbType string + type Dialect interface + AndStr func() string + AutoIncrStr func() string + CreateIndexSql func(tableName string, index *Index) string + CreateTableSql func(table *Table, tableName, storeEngine, charset string) string + DB func() *DB + DBType func() DbType + DataSourceName func() string + DriverName func() string + DropIndexSql func(tableName string, index *Index) string + DropTableSql func(tableName string) string + EqStr func() string + Filters func() []Filter + ForUpdateSql func(query string) string + FormatBytes func(b []byte) string + GetColumns func(tableName string) ([]string, map[string]*Column, error) + GetIndexes func(tableName string) (map[string]*Index, error) + GetTables func() ([]*Table, error) + IndexCheckSql func(tableName, idxName string) (string, []interface{}) + IndexOnTable func() bool + Init func(*DB, *Uri, string, string) error + IsColumnExist func(tableName string, colName string) (bool, error) + IsReserved func(string) bool + ModifyColumnSql func(tableName string, col *Column) string + OrStr func() string + Quote func(string) string + QuoteStr func() string + RollBackStr func() string + SetLogger func(logger ILogger) + ShowCreateNull func() bool + SqlType func(*Column) string + SupportCharset func() bool + SupportDropIfExists func() bool + SupportEngine func() bool + SupportInsertMany func() bool + TableCheckSql func(tableName string) (string, []interface{}) + URI func() *Uri + func QueryDialect(dbName DbType) Dialect + type Driver interface + Parse func(string, string) (*Uri, error) + func QueryDriver(driverName string) Driver + type EmptyScanner struct + func (EmptyScanner) Scan(src interface{}) error + type Filter interface + Do func(sql string, dialect Dialect, table *Table) string + type GonicMapper map[string]bool + func (mapper GonicMapper) Obj2Table(name string) string + func (mapper GonicMapper) Table2Obj(name string) string + type ILogger interface + Debug func(v ...interface{}) (err error) + Debugf func(format string, v ...interface{}) (err error) + Err func(v ...interface{}) (err error) + Errf func(format string, v ...interface{}) (err error) + Info func(v ...interface{}) (err error) + Infof func(format string, v ...interface{}) (err error) + Level func() LogLevel + SetLevel func(l LogLevel) (err error) + Warning func(v ...interface{}) (err error) + Warningf func(format string, v ...interface{}) (err error) + type IMapper interface + Obj2Table func(string) string + Table2Obj func(string) string + type IdFilter struct + func (i *IdFilter) Do(sql string, dialect Dialect, table *Table) string + type Index struct + Cols []string + IsRegular bool + Name string + Type int + func NewIndex(name string, indexType int) *Index + func (index *Index) AddColumn(cols ...string) + func (index *Index) Equal(dst *Index) bool + func (index *Index) XName(tableName string) string + type LogLevel int + const LOG_DEBUG + const LOG_ERR + const LOG_INFO + const LOG_OFF + const LOG_UNKNOWN + const LOG_WARNING + type PK []interface + func (p *PK) FromString(content string) error + func (p *PK) ToString() (string, error) + func GetCacheSql(m Cacher, tableName, sql string, args interface{}) ([]PK, error) + func NewPK(pks ...interface{}) *PK + type PrefixMapper struct + Mapper IMapper + Prefix string + func NewPrefixMapper(mapper IMapper, prefix string) PrefixMapper + func (mapper PrefixMapper) Obj2Table(name string) string + func (mapper PrefixMapper) Table2Obj(name string) string + type QuoteFilter struct + func (s *QuoteFilter) Do(sql string, dialect Dialect, table *Table) string + type Quoter struct + func NewQuoter(dialect Dialect) *Quoter + func (q *Quoter) Quote(content string) string + type Row struct + Mapper IMapper + func (row *Row) Scan(dest ...interface{}) error + type Rows struct + Mapper IMapper + func (rs *Rows) ScanMap(dest interface{}) error + func (rs *Rows) ScanSlice(dest interface{}) error + func (rs *Rows) ScanStructByIndex(dest ...interface{}) error + func (rs *Rows) ScanStructByName(dest interface{}) error + type SQLType struct + DefaultLength int + DefaultLength2 int + Name string + func Type2SQLType(t reflect.Type) (st SQLType) + func (s *SQLType) IsBlob() bool + func (s *SQLType) IsJson() bool + func (s *SQLType) IsNumeric() bool + func (s *SQLType) IsText() bool + func (s *SQLType) IsTime() bool + func (s *SQLType) IsType(st int) bool + type SameMapper struct + func (m SameMapper) Obj2Table(o string) string + func (m SameMapper) Table2Obj(t string) string + type SeqFilter struct + Prefix string + Start int + func (s *SeqFilter) Do(sql string, dialect Dialect, table *Table) string + type SnakeMapper struct + func (mapper SnakeMapper) Obj2Table(name string) string + func (mapper SnakeMapper) Table2Obj(name string) string + type Stmt struct + Mapper IMapper + func (s *Stmt) ExecMap(mp interface{}) (sql.Result, error) + func (s *Stmt) ExecStruct(st interface{}) (sql.Result, error) + func (s *Stmt) Query(args ...interface{}) (*Rows, error) + func (s *Stmt) QueryMap(mp interface{}) (*Rows, error) + func (s *Stmt) QueryRow(args ...interface{}) *Row + func (s *Stmt) QueryRowMap(mp interface{}) *Row + func (s *Stmt) QueryRowStruct(st interface{}) *Row + func (s *Stmt) QueryStruct(st interface{}) (*Rows, error) + type SuffixMapper struct + Mapper IMapper + Suffix string + func NewSuffixMapper(mapper IMapper, suffix string) SuffixMapper + func (mapper SuffixMapper) Obj2Table(name string) string + func (mapper SuffixMapper) Table2Obj(name string) string + type Table struct + AutoIncrement string + Cacher Cacher + Charset string + Created map[string]bool + Deleted string + Indexes map[string]*Index + Name string + PrimaryKeys []string + StoreEngine string + Type reflect.Type + Updated string + Version string + func NewEmptyTable() *Table + func NewTable(name string, t reflect.Type) *Table + func (table *Table) AddColumn(col *Column) + func (table *Table) AddIndex(index *Index) + func (table *Table) AutoIncrColumn() *Column + func (table *Table) ColumnType(name string) reflect.Type + func (table *Table) Columns() []*Column + func (table *Table) ColumnsSeq() []string + func (table *Table) DeletedColumn() *Column + func (table *Table) GetColumn(name string) *Column + func (table *Table) GetColumnIdx(name string, idx int) *Column + func (table *Table) PKColumns() []*Column + func (table *Table) UpdatedColumn() *Column + func (table *Table) VersionColumn() *Column + type Tx struct + Mapper IMapper + func (tx *Tx) ExecMap(query string, mp interface{}) (sql.Result, error) + func (tx *Tx) ExecStruct(query string, st interface{}) (sql.Result, error) + func (tx *Tx) Prepare(query string) (*Stmt, error) + func (tx *Tx) Query(query string, args ...interface{}) (*Rows, error) + func (tx *Tx) QueryMap(query string, mp interface{}) (*Rows, error) + func (tx *Tx) QueryRow(query string, args ...interface{}) *Row + func (tx *Tx) QueryRowMap(query string, mp interface{}) *Row + func (tx *Tx) QueryRowStruct(query string, st interface{}) *Row + func (tx *Tx) QueryStruct(query string, st interface{}) (*Rows, error) + func (tx *Tx) Stmt(stmt *Stmt) *Stmt + type Uri struct + Charset string + DbName string + DbType DbType + Host string + Laddr string + Passwd string + Port string + Proto string + Raddr string + Timeout time.Duration + User string