Merge branch 'master' of github.com:go-xorm/xorm
This commit is contained in:
commit
80c3483048
|
@ -92,7 +92,7 @@ func (m *LRUCacher) GC() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all bean's ids according to sql and parameter from cache
|
// GetIds returns all bean's ids according to sql and parameter from cache
|
||||||
func (m *LRUCacher) GetIds(tableName, sql string) interface{} {
|
func (m *LRUCacher) GetIds(tableName, sql string) interface{} {
|
||||||
m.mutex.Lock()
|
m.mutex.Lock()
|
||||||
defer m.mutex.Unlock()
|
defer m.mutex.Unlock()
|
||||||
|
@ -121,7 +121,7 @@ func (m *LRUCacher) GetIds(tableName, sql string) interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get bean according tableName and id from cache
|
// GetBean returns bean according tableName and id from cache
|
||||||
func (m *LRUCacher) GetBean(tableName string, id string) interface{} {
|
func (m *LRUCacher) GetBean(tableName string, id string) interface{} {
|
||||||
m.mutex.Lock()
|
m.mutex.Lock()
|
||||||
defer m.mutex.Unlock()
|
defer m.mutex.Unlock()
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
var _ core.CacheStore = NewMemoryStore()
|
var _ core.CacheStore = NewMemoryStore()
|
||||||
|
|
||||||
// memory store
|
// MemoryStore represents in-memory store
|
||||||
type MemoryStore struct {
|
type MemoryStore struct {
|
||||||
store map[interface{}]interface{}
|
store map[interface{}]interface{}
|
||||||
mutex sync.RWMutex
|
mutex sync.RWMutex
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -380,8 +379,7 @@ func (db *mssql) GetColumns(tableName string) ([]string, map[string]*core.Column
|
||||||
if _, ok := core.SqlTypes[ct]; ok {
|
if _, ok := core.SqlTypes[ct]; ok {
|
||||||
col.SQLType = core.SQLType{Name: ct, DefaultLength: 0, DefaultLength2: 0}
|
col.SQLType = core.SQLType{Name: ct, DefaultLength: 0, DefaultLength2: 0}
|
||||||
} else {
|
} else {
|
||||||
return nil, nil, errors.New(fmt.Sprintf("unknow colType %v for %v - %v",
|
return nil, nil, fmt.Errorf("Unknown colType %v for %v - %v", ct, tableName, col.Name)
|
||||||
ct, tableName, col.Name))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -375,7 +374,7 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
|
||||||
if _, ok := core.SqlTypes[colType]; ok {
|
if _, ok := core.SqlTypes[colType]; ok {
|
||||||
col.SQLType = core.SQLType{Name: colType, DefaultLength: len1, DefaultLength2: len2}
|
col.SQLType = core.SQLType{Name: colType, DefaultLength: len1, DefaultLength2: len2}
|
||||||
} else {
|
} else {
|
||||||
return nil, nil, errors.New(fmt.Sprintf("unkonw colType %v", colType))
|
return nil, nil, fmt.Errorf("Unknown colType %v", colType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if colKey == "PRI" {
|
if colKey == "PRI" {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -757,7 +756,7 @@ func (db *oracle) GetColumns(tableName string) ([]string, map[string]*core.Colum
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := core.SqlTypes[col.SQLType.Name]; !ok {
|
if _, ok := core.SqlTypes[col.SQLType.Name]; !ok {
|
||||||
return nil, nil, errors.New(fmt.Sprintf("unkonw colType %v %v", *dataType, col.SQLType))
|
return nil, nil, fmt.Errorf("Unknown colType %v %v", *dataType, col.SQLType)
|
||||||
}
|
}
|
||||||
|
|
||||||
col.Length = dataLen
|
col.Length = dataLen
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -990,7 +989,7 @@ WHERE c.relkind = 'r'::char AND c.relname = $1 AND s.table_schema = $2 AND f.att
|
||||||
col.SQLType = core.SQLType{Name: strings.ToUpper(dataType), DefaultLength: 0, DefaultLength2: 0}
|
col.SQLType = core.SQLType{Name: strings.ToUpper(dataType), DefaultLength: 0, DefaultLength2: 0}
|
||||||
}
|
}
|
||||||
if _, ok := core.SqlTypes[col.SQLType.Name]; !ok {
|
if _, ok := core.SqlTypes[col.SQLType.Name]; !ok {
|
||||||
return nil, nil, errors.New(fmt.Sprintf("unknow colType: %v", dataType))
|
return nil, nil, fmt.Errorf("Unknown colType: %v", dataType)
|
||||||
}
|
}
|
||||||
|
|
||||||
col.Length = maxLen
|
col.Length = maxLen
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
|
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
// Executed before an object is initially persisted to the database
|
// BeforeInsertProcessor executed before an object is initially persisted to the database
|
||||||
type BeforeInsertProcessor interface {
|
type BeforeInsertProcessor interface {
|
||||||
BeforeInsert()
|
BeforeInsert()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Executed before an object is updated
|
// BeforeUpdateProcessor executed before an object is updated
|
||||||
type BeforeUpdateProcessor interface {
|
type BeforeUpdateProcessor interface {
|
||||||
BeforeUpdate()
|
BeforeUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Executed before an object is deleted
|
// BeforeDeleteProcessor executed before an object is deleted
|
||||||
type BeforeDeleteProcessor interface {
|
type BeforeDeleteProcessor interface {
|
||||||
BeforeDelete()
|
BeforeDelete()
|
||||||
}
|
}
|
||||||
|
@ -34,17 +34,17 @@ type AfterSetProcessor interface {
|
||||||
//}
|
//}
|
||||||
// --
|
// --
|
||||||
|
|
||||||
// Executed after an object is persisted to the database
|
// AfterInsertProcessor executed after an object is persisted to the database
|
||||||
type AfterInsertProcessor interface {
|
type AfterInsertProcessor interface {
|
||||||
AfterInsert()
|
AfterInsert()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Executed after an object has been updated
|
// AfterUpdateProcessor executed after an object has been updated
|
||||||
type AfterUpdateProcessor interface {
|
type AfterUpdateProcessor interface {
|
||||||
AfterUpdate()
|
AfterUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Executed after an object has been deleted
|
// AfterDeleteProcessor executed after an object has been deleted
|
||||||
type AfterDeleteProcessor interface {
|
type AfterDeleteProcessor interface {
|
||||||
AfterDelete()
|
AfterDelete()
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,7 +371,7 @@ func (session *Session) DB() *core.DB {
|
||||||
return session.db
|
return session.db
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cond return session's conditions
|
// Conds returns session query conditions
|
||||||
func (session *Session) Conds() builder.Cond {
|
func (session *Session) Conds() builder.Cond {
|
||||||
return session.Statement.cond
|
return session.Statement.cond
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ func (statement *Statement) Alias(alias string) *Statement {
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sql add the raw sql statement
|
// SQL adds raw sql statement
|
||||||
func (statement *Statement) SQL(query interface{}, args ...interface{}) *Statement {
|
func (statement *Statement) SQL(query interface{}, args ...interface{}) *Statement {
|
||||||
switch query.(type) {
|
switch query.(type) {
|
||||||
case (*builder.Builder):
|
case (*builder.Builder):
|
||||||
|
@ -795,14 +795,14 @@ func (statement *Statement) col2NewColsWithQuote(columns ...string) []string {
|
||||||
return newColumns
|
return newColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate "Distince col1, col2 " statment
|
// Distinct generates "DISTINCT col1, col2 " statement
|
||||||
func (statement *Statement) Distinct(columns ...string) *Statement {
|
func (statement *Statement) Distinct(columns ...string) *Statement {
|
||||||
statement.IsDistinct = true
|
statement.IsDistinct = true
|
||||||
statement.Cols(columns...)
|
statement.Cols(columns...)
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate "SELECT ... FOR UPDATE" statment
|
// ForUpdate generates "SELECT ... FOR UPDATE" statement
|
||||||
func (statement *Statement) ForUpdate() *Statement {
|
func (statement *Statement) ForUpdate() *Statement {
|
||||||
statement.IsForUpdate = true
|
statement.IsForUpdate = true
|
||||||
return statement
|
return statement
|
||||||
|
|
Loading…
Reference in New Issue