Merge branch 'master' into feature/named-parameters
This commit is contained in:
commit
9479269f4a
@ -3,7 +3,7 @@ package gorm
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// DefaultCallback default callbacks defined by gorm
|
// DefaultCallback default callbacks defined by gorm
|
||||||
var DefaultCallback = &Callback{}
|
var DefaultCallback = &Callback{logger: nopLogger{}}
|
||||||
|
|
||||||
// Callback is a struct that contains all CRUD callbacks
|
// Callback is a struct that contains all CRUD callbacks
|
||||||
// Field `creates` contains callbacks will be call when creating object
|
// Field `creates` contains callbacks will be call when creating object
|
||||||
@ -101,6 +101,7 @@ func (cp *CallbackProcessor) Register(callbackName string, callback func(scope *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cp.logger.Print("info", fmt.Sprintf("[info] registering callback `%v` from %v", callbackName, fileWithLineNum()))
|
||||||
cp.name = callbackName
|
cp.name = callbackName
|
||||||
cp.processor = &callback
|
cp.processor = &callback
|
||||||
cp.parent.processors = append(cp.parent.processors, cp)
|
cp.parent.processors = append(cp.parent.processors, cp)
|
||||||
|
@ -50,7 +50,7 @@ func updateTimeStampForCreateCallback(scope *Scope) {
|
|||||||
// createCallback the callback used to insert data into database
|
// createCallback the callback used to insert data into database
|
||||||
func createCallback(scope *Scope) {
|
func createCallback(scope *Scope) {
|
||||||
if !scope.HasError() {
|
if !scope.HasError() {
|
||||||
defer scope.trace(scope.db.nowFunc())
|
defer scope.trace(NowFunc())
|
||||||
|
|
||||||
var (
|
var (
|
||||||
columns, placeholders []string
|
columns, placeholders []string
|
||||||
@ -100,8 +100,11 @@ func createCallback(scope *Scope) {
|
|||||||
returningColumn = scope.Quote(primaryField.DBName)
|
returningColumn = scope.Quote(primaryField.DBName)
|
||||||
}
|
}
|
||||||
|
|
||||||
lastInsertIDReturningSuffix := scope.Dialect().LastInsertIDReturningSuffix(quotedTableName, returningColumn)
|
|
||||||
lastInsertIDOutputInterstitial := scope.Dialect().LastInsertIDOutputInterstitial(quotedTableName, returningColumn, columns)
|
lastInsertIDOutputInterstitial := scope.Dialect().LastInsertIDOutputInterstitial(quotedTableName, returningColumn, columns)
|
||||||
|
var lastInsertIDReturningSuffix string
|
||||||
|
if lastInsertIDOutputInterstitial == "" {
|
||||||
|
lastInsertIDReturningSuffix = scope.Dialect().LastInsertIDReturningSuffix(quotedTableName, returningColumn)
|
||||||
|
}
|
||||||
|
|
||||||
if len(columns) == 0 {
|
if len(columns) == 0 {
|
||||||
scope.Raw(fmt.Sprintf(
|
scope.Raw(fmt.Sprintf(
|
||||||
|
@ -24,7 +24,7 @@ func queryCallback(scope *Scope) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
defer scope.trace(scope.db.nowFunc())
|
defer scope.trace(NowFunc())
|
||||||
|
|
||||||
var (
|
var (
|
||||||
isSlice, isPtr bool
|
isSlice, isPtr bool
|
||||||
@ -60,6 +60,11 @@ func queryCallback(scope *Scope) {
|
|||||||
|
|
||||||
if !scope.HasError() {
|
if !scope.HasError() {
|
||||||
scope.db.RowsAffected = 0
|
scope.db.RowsAffected = 0
|
||||||
|
|
||||||
|
if str, ok := scope.Get("gorm:query_hint"); ok {
|
||||||
|
scope.SQL = fmt.Sprint(str) + scope.SQL
|
||||||
|
}
|
||||||
|
|
||||||
if str, ok := scope.Get("gorm:query_option"); ok {
|
if str, ok := scope.Get("gorm:query_option"); ok {
|
||||||
scope.SQL += addExtraSpaceIfExist(fmt.Sprint(str))
|
scope.SQL += addExtraSpaceIfExist(fmt.Sprint(str))
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,11 @@ type RowsQueryResult struct {
|
|||||||
func rowQueryCallback(scope *Scope) {
|
func rowQueryCallback(scope *Scope) {
|
||||||
if result, ok := scope.InstanceGet("row_query_result"); ok {
|
if result, ok := scope.InstanceGet("row_query_result"); ok {
|
||||||
scope.prepareQuerySQL()
|
scope.prepareQuerySQL()
|
||||||
|
|
||||||
|
if str, ok := scope.Get("gorm:query_hint"); ok {
|
||||||
|
scope.SQL = fmt.Sprint(str) + scope.SQL
|
||||||
|
}
|
||||||
|
|
||||||
if str, ok := scope.Get("gorm:query_option"); ok {
|
if str, ok := scope.Get("gorm:query_option"); ok {
|
||||||
scope.SQL += addExtraSpaceIfExist(fmt.Sprint(str))
|
scope.SQL += addExtraSpaceIfExist(fmt.Sprint(str))
|
||||||
}
|
}
|
||||||
|
@ -217,3 +217,33 @@ func TestGetCallback(t *testing.T) {
|
|||||||
t.Errorf("`gorm:test_callback_value` should be `3, true` but `%v, %v`", v, ok)
|
t.Errorf("`gorm:test_callback_value` should be `3, true` but `%v, %v`", v, ok)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUseDefaultCallback(t *testing.T) {
|
||||||
|
createCallbackName := "gorm:test_use_default_callback_for_create"
|
||||||
|
gorm.DefaultCallback.Create().Register(createCallbackName, func(*gorm.Scope) {
|
||||||
|
// nop
|
||||||
|
})
|
||||||
|
if gorm.DefaultCallback.Create().Get(createCallbackName) == nil {
|
||||||
|
t.Errorf("`%s` expected non-nil, but got nil", createCallbackName)
|
||||||
|
}
|
||||||
|
gorm.DefaultCallback.Create().Remove(createCallbackName)
|
||||||
|
if gorm.DefaultCallback.Create().Get(createCallbackName) != nil {
|
||||||
|
t.Errorf("`%s` expected nil, but got non-nil", createCallbackName)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCallbackName := "gorm:test_use_default_callback_for_update"
|
||||||
|
scopeValueName := "gorm:test_use_default_callback_for_update_value"
|
||||||
|
gorm.DefaultCallback.Update().Register(updateCallbackName, func(scope *gorm.Scope) {
|
||||||
|
scope.Set(scopeValueName, 1)
|
||||||
|
})
|
||||||
|
gorm.DefaultCallback.Update().Replace(updateCallbackName, func(scope *gorm.Scope) {
|
||||||
|
scope.Set(scopeValueName, 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
scope := DB.NewScope(nil)
|
||||||
|
callback := gorm.DefaultCallback.Update().Get(updateCallbackName)
|
||||||
|
callback(scope)
|
||||||
|
if v, ok := scope.Get(scopeValueName); !ok || v != 2 {
|
||||||
|
t.Errorf("`%s` should be `2, true` but `%v, %v`", scopeValueName, v, ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -37,7 +37,7 @@ type Dialect interface {
|
|||||||
ModifyColumn(tableName string, columnName string, typ string) error
|
ModifyColumn(tableName string, columnName string, typ string) error
|
||||||
|
|
||||||
// LimitAndOffsetSQL return generated SQL with Limit and Offset, as mssql has special case
|
// LimitAndOffsetSQL return generated SQL with Limit and Offset, as mssql has special case
|
||||||
LimitAndOffsetSQL(limit, offset interface{}) string
|
LimitAndOffsetSQL(limit, offset interface{}) (string, error)
|
||||||
// SelectFromDummyTable return select values, for most dbs, `SELECT values` just works, mysql needs `SELECT value FROM DUAL`
|
// SelectFromDummyTable return select values, for most dbs, `SELECT values` just works, mysql needs `SELECT value FROM DUAL`
|
||||||
SelectFromDummyTable() string
|
SelectFromDummyTable() string
|
||||||
// LastInsertIDOutputInterstitial most dbs support LastInsertId, but mssql needs to use `OUTPUT`
|
// LastInsertIDOutputInterstitial most dbs support LastInsertId, but mssql needs to use `OUTPUT`
|
||||||
|
@ -139,14 +139,19 @@ func (s commonDialect) CurrentDatabase() (name string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (commonDialect) LimitAndOffsetSQL(limit, offset interface{}) (sql string) {
|
// LimitAndOffsetSQL return generated SQL with Limit and Offset
|
||||||
|
func (s commonDialect) LimitAndOffsetSQL(limit, offset interface{}) (sql string, err error) {
|
||||||
if limit != nil {
|
if limit != nil {
|
||||||
if parsedLimit, err := strconv.ParseInt(fmt.Sprint(limit), 0, 0); err == nil && parsedLimit >= 0 {
|
if parsedLimit, err := s.parseInt(limit); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else if parsedLimit >= 0 {
|
||||||
sql += fmt.Sprintf(" LIMIT %d", parsedLimit)
|
sql += fmt.Sprintf(" LIMIT %d", parsedLimit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if offset != nil {
|
if offset != nil {
|
||||||
if parsedOffset, err := strconv.ParseInt(fmt.Sprint(offset), 0, 0); err == nil && parsedOffset >= 0 {
|
if parsedOffset, err := s.parseInt(offset); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else if parsedOffset >= 0 {
|
||||||
sql += fmt.Sprintf(" OFFSET %d", parsedOffset)
|
sql += fmt.Sprintf(" OFFSET %d", parsedOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,6 +186,10 @@ func (commonDialect) NormalizeIndexAndColumn(indexName, columnName string) (stri
|
|||||||
return indexName, columnName
|
return indexName, columnName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (commonDialect) parseInt(value interface{}) (int64, error) {
|
||||||
|
return strconv.ParseInt(fmt.Sprint(value), 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
// IsByteArrayOrSlice returns true of the reflected value is an array or slice
|
// IsByteArrayOrSlice returns true of the reflected value is an array or slice
|
||||||
func IsByteArrayOrSlice(value reflect.Value) bool {
|
func IsByteArrayOrSlice(value reflect.Value) bool {
|
||||||
return (value.Kind() == reflect.Array || value.Kind() == reflect.Slice) && value.Type().Elem() == reflect.TypeOf(uint8(0))
|
return (value.Kind() == reflect.Array || value.Kind() == reflect.Slice) && value.Type().Elem() == reflect.TypeOf(uint8(0))
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@ -140,13 +139,21 @@ func (s mysql) ModifyColumn(tableName string, columnName string, typ string) err
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s mysql) LimitAndOffsetSQL(limit, offset interface{}) (sql string) {
|
func (s mysql) LimitAndOffsetSQL(limit, offset interface{}) (sql string, err error) {
|
||||||
if limit != nil {
|
if limit != nil {
|
||||||
if parsedLimit, err := strconv.ParseInt(fmt.Sprint(limit), 0, 0); err == nil && parsedLimit >= 0 {
|
parsedLimit, err := s.parseInt(limit)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if parsedLimit >= 0 {
|
||||||
sql += fmt.Sprintf(" LIMIT %d", parsedLimit)
|
sql += fmt.Sprintf(" LIMIT %d", parsedLimit)
|
||||||
|
|
||||||
if offset != nil {
|
if offset != nil {
|
||||||
if parsedOffset, err := strconv.ParseInt(fmt.Sprint(offset), 0, 0); err == nil && parsedOffset >= 0 {
|
parsedOffset, err := s.parseInt(offset)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if parsedOffset >= 0 {
|
||||||
sql += fmt.Sprintf(" OFFSET %d", parsedOffset)
|
sql += fmt.Sprintf(" OFFSET %d", parsedOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,14 +168,22 @@ func (s mssql) CurrentDatabase() (name string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mssql) LimitAndOffsetSQL(limit, offset interface{}) (sql string) {
|
func parseInt(value interface{}) (int64, error) {
|
||||||
|
return strconv.ParseInt(fmt.Sprint(value), 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mssql) LimitAndOffsetSQL(limit, offset interface{}) (sql string, err error) {
|
||||||
if offset != nil {
|
if offset != nil {
|
||||||
if parsedOffset, err := strconv.ParseInt(fmt.Sprint(offset), 0, 0); err == nil && parsedOffset >= 0 {
|
if parsedOffset, err := parseInt(offset); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else if parsedOffset >= 0 {
|
||||||
sql += fmt.Sprintf(" OFFSET %d ROWS", parsedOffset)
|
sql += fmt.Sprintf(" OFFSET %d ROWS", parsedOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if limit != nil {
|
if limit != nil {
|
||||||
if parsedLimit, err := strconv.ParseInt(fmt.Sprint(limit), 0, 0); err == nil && parsedLimit >= 0 {
|
if parsedLimit, err := parseInt(limit); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else if parsedLimit >= 0 {
|
||||||
if sql == "" {
|
if sql == "" {
|
||||||
// add default zero offset
|
// add default zero offset
|
||||||
sql += " OFFSET 0 ROWS"
|
sql += " OFFSET 0 ROWS"
|
||||||
@ -199,7 +207,8 @@ func (mssql) LastInsertIDOutputInterstitial(tableName, columnName string, column
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mssql) LastInsertIDReturningSuffix(tableName, columnName string) string {
|
func (mssql) LastInsertIDReturningSuffix(tableName, columnName string) string {
|
||||||
return ""
|
// https://stackoverflow.com/questions/5228780/how-to-get-last-inserted-id
|
||||||
|
return "; SELECT SCOPE_IDENTITY()"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mssql) DefaultValueStr() string {
|
func (mssql) DefaultValueStr() string {
|
||||||
|
6
go.mod
6
go.mod
@ -3,11 +3,13 @@ module github.com/jinzhu/gorm
|
|||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3
|
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd
|
||||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5
|
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5
|
||||||
github.com/go-sql-driver/mysql v1.4.1
|
github.com/go-sql-driver/mysql v1.4.1
|
||||||
github.com/jinzhu/inflection v1.0.0
|
github.com/jinzhu/inflection v1.0.0
|
||||||
github.com/jinzhu/now v1.0.1
|
github.com/jinzhu/now v1.0.1
|
||||||
github.com/lib/pq v1.1.1
|
github.com/lib/pq v1.1.1
|
||||||
github.com/mattn/go-sqlite3 v1.11.0
|
github.com/mattn/go-sqlite3 v2.0.1+incompatible
|
||||||
|
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd // indirect
|
||||||
|
google.golang.org/appengine v1.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
122
go.sum
122
go.sum
@ -1,131 +1,29 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
|
||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||||
cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU=
|
|
||||||
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
|
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
|
||||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
|
||||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
|
||||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3 h1:tkum0XDgfR0jcVVXuTsYv/erY2NnEDqwRojbxR1rBYA=
|
|
||||||
github.com/denisenkom/go-mssqldb v0.0.0-20190515213511-eb9f6a1743f3/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM=
|
|
||||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
|
||||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
|
||||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
|
||||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
|
||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
|
||||||
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
|
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
|
||||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
|
||||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
|
||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
|
||||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
|
||||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
|
||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
|
||||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
|
||||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
|
||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
|
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
|
||||||
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
|
||||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
|
||||||
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=
|
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
|
||||||
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
|
||||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
|
||||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
|
||||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
|
||||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
|
||||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
|
||||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
|
||||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
|
||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
|
||||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
|
||||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI=
|
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI=
|
||||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd h1:GGJVjV8waZKRHrgwvtH66z9ZGVurTD1MT0n1Bb+q4aM=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
|
||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
|
||||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
|
||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
|
||||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
|
||||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
|
||||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
|
||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
||||||
|
13
logger.go
13
logger.go
@ -39,6 +39,15 @@ var LogFormatter = func(values ...interface{}) (messages []interface{}) {
|
|||||||
|
|
||||||
messages = []interface{}{source, currentTime}
|
messages = []interface{}{source, currentTime}
|
||||||
|
|
||||||
|
if len(values) == 2 {
|
||||||
|
//remove the line break
|
||||||
|
currentTime = currentTime[1:]
|
||||||
|
//remove the brackets
|
||||||
|
source = fmt.Sprintf("\033[35m%v\033[0m", values[1])
|
||||||
|
|
||||||
|
messages = []interface{}{currentTime, source}
|
||||||
|
}
|
||||||
|
|
||||||
if level == "sql" {
|
if level == "sql" {
|
||||||
// duration
|
// duration
|
||||||
messages = append(messages, fmt.Sprintf(" \033[36;1m[%.2fms]\033[0m ", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0))
|
messages = append(messages, fmt.Sprintf(" \033[36;1m[%.2fms]\033[0m ", float64(values[2].(time.Duration).Nanoseconds()/1e4)/100.0))
|
||||||
@ -126,3 +135,7 @@ type Logger struct {
|
|||||||
func (logger Logger) Print(values ...interface{}) {
|
func (logger Logger) Print(values ...interface{}) {
|
||||||
logger.Println(LogFormatter(values...)...)
|
logger.Println(LogFormatter(values...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type nopLogger struct{}
|
||||||
|
|
||||||
|
func (nopLogger) Print(values ...interface{}) {}
|
||||||
|
29
main.go
29
main.go
@ -124,7 +124,10 @@ func (s *DB) Close() error {
|
|||||||
// DB get `*sql.DB` from current connection
|
// DB get `*sql.DB` from current connection
|
||||||
// If the underlying database connection is not a *sql.DB, returns nil
|
// If the underlying database connection is not a *sql.DB, returns nil
|
||||||
func (s *DB) DB() *sql.DB {
|
func (s *DB) DB() *sql.DB {
|
||||||
db, _ := s.db.(*sql.DB)
|
db, ok := s.db.(*sql.DB)
|
||||||
|
if !ok {
|
||||||
|
panic("can't support full GORM on currently status, maybe this is a TX instance.")
|
||||||
|
}
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,6 +437,7 @@ func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update update attributes with callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update
|
// Update update attributes with callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update
|
||||||
|
// WARNING when update with struct, GORM will not update fields that with zero value
|
||||||
func (s *DB) Update(attrs ...interface{}) *DB {
|
func (s *DB) Update(attrs ...interface{}) *DB {
|
||||||
return s.Updates(toSearchableMap(attrs...), true)
|
return s.Updates(toSearchableMap(attrs...), true)
|
||||||
}
|
}
|
||||||
@ -480,6 +484,7 @@ func (s *DB) Create(value interface{}) *DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete delete value match given conditions, if the value has primary key, then will including the primary key as condition
|
// Delete delete value match given conditions, if the value has primary key, then will including the primary key as condition
|
||||||
|
// WARNING If model has DeletedAt field, GORM will only set field DeletedAt's value to current time
|
||||||
func (s *DB) Delete(value interface{}, where ...interface{}) *DB {
|
func (s *DB) Delete(value interface{}, where ...interface{}) *DB {
|
||||||
return s.NewScope(value).inlineCondition(where...).callCallbacks(s.parent.callbacks.deletes).db
|
return s.NewScope(value).inlineCondition(where...).callCallbacks(s.parent.callbacks.deletes).db
|
||||||
}
|
}
|
||||||
@ -523,6 +528,28 @@ func (s *DB) Debug() *DB {
|
|||||||
return s.clone().LogMode(true)
|
return s.clone().LogMode(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transaction start a transaction as a block,
|
||||||
|
// return error will rollback, otherwise to commit.
|
||||||
|
func (s *DB) Transaction(fc func(tx *DB) error) (err error) {
|
||||||
|
panicked := true
|
||||||
|
tx := s.Begin()
|
||||||
|
defer func() {
|
||||||
|
// Make sure to rollback when panic, Block error or Commit error
|
||||||
|
if panicked || err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
err = fc(tx)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
err = tx.Commit().Error
|
||||||
|
}
|
||||||
|
|
||||||
|
panicked = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Begin begins a transaction
|
// Begin begins a transaction
|
||||||
func (s *DB) Begin() *DB {
|
func (s *DB) Begin() *DB {
|
||||||
return s.BeginTx(context.Background(), &sql.TxOptions{})
|
return s.BeginTx(context.Background(), &sql.TxOptions{})
|
||||||
|
95
main_test.go
95
main_test.go
@ -8,6 +8,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -469,6 +470,76 @@ func TestTransaction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func assertPanic(t *testing.T, f func()) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r == nil {
|
||||||
|
t.Errorf("The code did not panic")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
f()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTransactionWithBlock(t *testing.T) {
|
||||||
|
// rollback
|
||||||
|
err := DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
u := User{Name: "transcation"}
|
||||||
|
if err := tx.Save(&u).Error; err != nil {
|
||||||
|
t.Errorf("No error should raise")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.First(&User{}, "name = ?", "transcation").Error; err != nil {
|
||||||
|
t.Errorf("Should find saved record")
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.New("the error message")
|
||||||
|
})
|
||||||
|
|
||||||
|
if err.Error() != "the error message" {
|
||||||
|
t.Errorf("Transaction return error will equal the block returns error")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := DB.First(&User{}, "name = ?", "transcation").Error; err == nil {
|
||||||
|
t.Errorf("Should not find record after rollback")
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit
|
||||||
|
DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
u2 := User{Name: "transcation-2"}
|
||||||
|
if err := tx.Save(&u2).Error; err != nil {
|
||||||
|
t.Errorf("No error should raise")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.First(&User{}, "name = ?", "transcation-2").Error; err != nil {
|
||||||
|
t.Errorf("Should find saved record")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := DB.First(&User{}, "name = ?", "transcation-2").Error; err != nil {
|
||||||
|
t.Errorf("Should be able to find committed record")
|
||||||
|
}
|
||||||
|
|
||||||
|
// panic will rollback
|
||||||
|
assertPanic(t, func() {
|
||||||
|
DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
u3 := User{Name: "transcation-3"}
|
||||||
|
if err := tx.Save(&u3).Error; err != nil {
|
||||||
|
t.Errorf("No error should raise")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.First(&User{}, "name = ?", "transcation-3").Error; err != nil {
|
||||||
|
t.Errorf("Should find saved record")
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("force panic")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := DB.First(&User{}, "name = ?", "transcation").Error; err == nil {
|
||||||
|
t.Errorf("Should not find record after panic rollback")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestTransaction_NoErrorOnRollbackAfterCommit(t *testing.T) {
|
func TestTransaction_NoErrorOnRollbackAfterCommit(t *testing.T) {
|
||||||
tx := DB.Begin()
|
tx := DB.Begin()
|
||||||
u := User{Name: "transcation"}
|
u := User{Name: "transcation"}
|
||||||
@ -1262,6 +1333,30 @@ func TestCountWithQueryOption(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestQueryHint1(t *testing.T) {
|
||||||
|
db := DB.New()
|
||||||
|
|
||||||
|
_, err := db.Model(User{}).Raw("select 1").Rows()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Error("Unexpected error on query count with query_option")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestQueryHint2(t *testing.T) {
|
||||||
|
type TestStruct struct {
|
||||||
|
ID string `gorm:"primary_key"`
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
DB.DropTable(&TestStruct{})
|
||||||
|
DB.AutoMigrate(&TestStruct{})
|
||||||
|
|
||||||
|
data := TestStruct{ID: "uuid", Name: "hello"}
|
||||||
|
if err := DB.Set("gorm:query_hint", "/*master*/").Save(&data).Error; err != nil {
|
||||||
|
t.Error("Unexpected error on query count with query_option")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFloatColumnPrecision(t *testing.T) {
|
func TestFloatColumnPrecision(t *testing.T) {
|
||||||
if dialect := os.Getenv("GORM_DIALECT"); dialect != "mysql" && dialect != "sqlite" {
|
if dialect := os.Getenv("GORM_DIALECT"); dialect != "mysql" && dialect != "sqlite" {
|
||||||
t.Skip()
|
t.Skip()
|
||||||
|
@ -17,6 +17,10 @@ var DefaultTableNameHandler = func(db *DB, defaultTableName string) string {
|
|||||||
return defaultTableName
|
return defaultTableName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lock for mutating global cached model metadata
|
||||||
|
var structsLock sync.Mutex
|
||||||
|
|
||||||
|
// global cache of model metadata
|
||||||
var modelStructsMap sync.Map
|
var modelStructsMap sync.Map
|
||||||
|
|
||||||
// ModelStruct model definition
|
// ModelStruct model definition
|
||||||
@ -419,8 +423,12 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
|
|||||||
for idx, foreignKey := range foreignKeys {
|
for idx, foreignKey := range foreignKeys {
|
||||||
if foreignField := getForeignField(foreignKey, toFields); foreignField != nil {
|
if foreignField := getForeignField(foreignKey, toFields); foreignField != nil {
|
||||||
if associationField := getForeignField(associationForeignKeys[idx], modelStruct.StructFields); associationField != nil {
|
if associationField := getForeignField(associationForeignKeys[idx], modelStruct.StructFields); associationField != nil {
|
||||||
// source foreign keys
|
// mark field as foreignkey, use global lock to avoid race
|
||||||
|
structsLock.Lock()
|
||||||
foreignField.IsForeignKey = true
|
foreignField.IsForeignKey = true
|
||||||
|
structsLock.Unlock()
|
||||||
|
|
||||||
|
// association foreign keys
|
||||||
relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, associationField.Name)
|
relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, associationField.Name)
|
||||||
relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, associationField.DBName)
|
relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, associationField.DBName)
|
||||||
|
|
||||||
@ -523,8 +531,12 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
|
|||||||
for idx, foreignKey := range foreignKeys {
|
for idx, foreignKey := range foreignKeys {
|
||||||
if foreignField := getForeignField(foreignKey, toFields); foreignField != nil {
|
if foreignField := getForeignField(foreignKey, toFields); foreignField != nil {
|
||||||
if scopeField := getForeignField(associationForeignKeys[idx], modelStruct.StructFields); scopeField != nil {
|
if scopeField := getForeignField(associationForeignKeys[idx], modelStruct.StructFields); scopeField != nil {
|
||||||
|
// mark field as foreignkey, use global lock to avoid race
|
||||||
|
structsLock.Lock()
|
||||||
foreignField.IsForeignKey = true
|
foreignField.IsForeignKey = true
|
||||||
// source foreign keys
|
structsLock.Unlock()
|
||||||
|
|
||||||
|
// association foreign keys
|
||||||
relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, scopeField.Name)
|
relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, scopeField.Name)
|
||||||
relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, scopeField.DBName)
|
relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, scopeField.DBName)
|
||||||
|
|
||||||
@ -582,7 +594,10 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
|
|||||||
for idx, foreignKey := range foreignKeys {
|
for idx, foreignKey := range foreignKeys {
|
||||||
if foreignField := getForeignField(foreignKey, modelStruct.StructFields); foreignField != nil {
|
if foreignField := getForeignField(foreignKey, modelStruct.StructFields); foreignField != nil {
|
||||||
if associationField := getForeignField(associationForeignKeys[idx], toFields); associationField != nil {
|
if associationField := getForeignField(associationForeignKeys[idx], toFields); associationField != nil {
|
||||||
|
// mark field as foreignkey, use global lock to avoid race
|
||||||
|
structsLock.Lock()
|
||||||
foreignField.IsForeignKey = true
|
foreignField.IsForeignKey = true
|
||||||
|
structsLock.Unlock()
|
||||||
|
|
||||||
// association foreign keys
|
// association foreign keys
|
||||||
relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, associationField.Name)
|
relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, associationField.Name)
|
||||||
|
93
model_struct_test.go
Normal file
93
model_struct_test.go
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package gorm_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/jinzhu/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ModelA struct {
|
||||||
|
gorm.Model
|
||||||
|
Name string
|
||||||
|
|
||||||
|
ModelCs []ModelC `gorm:"foreignkey:OtherAID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModelB struct {
|
||||||
|
gorm.Model
|
||||||
|
Name string
|
||||||
|
|
||||||
|
ModelCs []ModelC `gorm:"foreignkey:OtherBID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModelC struct {
|
||||||
|
gorm.Model
|
||||||
|
Name string
|
||||||
|
|
||||||
|
OtherAID uint64
|
||||||
|
OtherA *ModelA `gorm:"foreignkey:OtherAID"`
|
||||||
|
OtherBID uint64
|
||||||
|
OtherB *ModelB `gorm:"foreignkey:OtherBID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// This test will try to cause a race condition on the model's foreignkey metadata
|
||||||
|
func TestModelStructRaceSameModel(t *testing.T) {
|
||||||
|
// use a WaitGroup to execute as much in-sync as possible
|
||||||
|
// it's more likely to hit a race condition than without
|
||||||
|
n := 32
|
||||||
|
start := sync.WaitGroup{}
|
||||||
|
start.Add(n)
|
||||||
|
|
||||||
|
// use another WaitGroup to know when the test is done
|
||||||
|
done := sync.WaitGroup{}
|
||||||
|
done.Add(n)
|
||||||
|
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
go func() {
|
||||||
|
start.Wait()
|
||||||
|
|
||||||
|
// call GetStructFields, this had a race condition before we fixed it
|
||||||
|
DB.NewScope(&ModelA{}).GetStructFields()
|
||||||
|
|
||||||
|
done.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
|
start.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
done.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
// This test will try to cause a race condition on the model's foreignkey metadata
|
||||||
|
func TestModelStructRaceDifferentModel(t *testing.T) {
|
||||||
|
// use a WaitGroup to execute as much in-sync as possible
|
||||||
|
// it's more likely to hit a race condition than without
|
||||||
|
n := 32
|
||||||
|
start := sync.WaitGroup{}
|
||||||
|
start.Add(n)
|
||||||
|
|
||||||
|
// use another WaitGroup to know when the test is done
|
||||||
|
done := sync.WaitGroup{}
|
||||||
|
done.Add(n)
|
||||||
|
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
i := i
|
||||||
|
go func() {
|
||||||
|
start.Wait()
|
||||||
|
|
||||||
|
// call GetStructFields, this had a race condition before we fixed it
|
||||||
|
if i%2 == 0 {
|
||||||
|
DB.NewScope(&ModelA{}).GetStructFields()
|
||||||
|
} else {
|
||||||
|
DB.NewScope(&ModelB{}).GetStructFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
done.Done()
|
||||||
|
}()
|
||||||
|
|
||||||
|
start.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
done.Wait()
|
||||||
|
}
|
@ -457,6 +457,74 @@ func TestOffset(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLimitAndOffsetSQL(t *testing.T) {
|
||||||
|
user1 := User{Name: "TestLimitAndOffsetSQL1", Age: 10}
|
||||||
|
user2 := User{Name: "TestLimitAndOffsetSQL2", Age: 20}
|
||||||
|
user3 := User{Name: "TestLimitAndOffsetSQL3", Age: 30}
|
||||||
|
user4 := User{Name: "TestLimitAndOffsetSQL4", Age: 40}
|
||||||
|
user5 := User{Name: "TestLimitAndOffsetSQL5", Age: 50}
|
||||||
|
if err := DB.Save(&user1).Save(&user2).Save(&user3).Save(&user4).Save(&user5).Error; err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
limit, offset interface{}
|
||||||
|
users []*User
|
||||||
|
ok bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "OK",
|
||||||
|
limit: float64(2),
|
||||||
|
offset: float64(2),
|
||||||
|
users: []*User{
|
||||||
|
&User{Name: "TestLimitAndOffsetSQL3", Age: 30},
|
||||||
|
&User{Name: "TestLimitAndOffsetSQL2", Age: 20},
|
||||||
|
},
|
||||||
|
ok: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Limit parse error",
|
||||||
|
limit: float64(1000000), // 1e+06
|
||||||
|
offset: float64(2),
|
||||||
|
ok: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Offset parse error",
|
||||||
|
limit: float64(2),
|
||||||
|
offset: float64(1000000), // 1e+06
|
||||||
|
ok: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
var users []*User
|
||||||
|
err := DB.Where("name LIKE ?", "TestLimitAndOffsetSQL%").Order("age desc").Limit(tt.limit).Offset(tt.offset).Find(&users).Error
|
||||||
|
if tt.ok {
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error expected nil, but got %v", err)
|
||||||
|
}
|
||||||
|
if len(users) != len(tt.users) {
|
||||||
|
t.Errorf("users length expected %d, but got %d", len(tt.users), len(users))
|
||||||
|
}
|
||||||
|
for i := range tt.users {
|
||||||
|
if users[i].Name != tt.users[i].Name {
|
||||||
|
t.Errorf("users[%d] name expected %s, but got %s", i, tt.users[i].Name, users[i].Name)
|
||||||
|
}
|
||||||
|
if users[i].Age != tt.users[i].Age {
|
||||||
|
t.Errorf("users[%d] age expected %d, but got %d", i, tt.users[i].Age, users[i].Age)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err == nil {
|
||||||
|
t.Error("error expected not nil, but got nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestOr(t *testing.T) {
|
func TestOr(t *testing.T) {
|
||||||
user1 := User{Name: "OrUser1", Age: 1}
|
user1 := User{Name: "OrUser1", Age: 1}
|
||||||
user2 := User{Name: "OrUser2", Age: 10}
|
user2 := User{Name: "OrUser2", Age: 10}
|
||||||
|
10
scope.go
10
scope.go
@ -358,7 +358,7 @@ func (scope *Scope) Raw(sql string) *Scope {
|
|||||||
|
|
||||||
// Exec perform generated SQL
|
// Exec perform generated SQL
|
||||||
func (scope *Scope) Exec() *Scope {
|
func (scope *Scope) Exec() *Scope {
|
||||||
defer scope.trace(scope.db.nowFunc())
|
defer scope.trace(NowFunc())
|
||||||
|
|
||||||
if !scope.HasError() {
|
if !scope.HasError() {
|
||||||
if result, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...); scope.Err(err) == nil {
|
if result, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...); scope.Err(err) == nil {
|
||||||
@ -842,7 +842,9 @@ func (scope *Scope) orderSQL() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (scope *Scope) limitAndOffsetSQL() string {
|
func (scope *Scope) limitAndOffsetSQL() string {
|
||||||
return scope.Dialect().LimitAndOffsetSQL(scope.Search.limit, scope.Search.offset)
|
sql, err := scope.Dialect().LimitAndOffsetSQL(scope.Search.limit, scope.Search.offset)
|
||||||
|
scope.Err(err)
|
||||||
|
return sql
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scope *Scope) groupSQL() string {
|
func (scope *Scope) groupSQL() string {
|
||||||
@ -977,7 +979,7 @@ func (scope *Scope) updatedAttrsWithValues(value interface{}) (results map[strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (scope *Scope) row() *sql.Row {
|
func (scope *Scope) row() *sql.Row {
|
||||||
defer scope.trace(scope.db.nowFunc())
|
defer scope.trace(NowFunc())
|
||||||
|
|
||||||
result := &RowQueryResult{}
|
result := &RowQueryResult{}
|
||||||
scope.InstanceSet("row_query_result", result)
|
scope.InstanceSet("row_query_result", result)
|
||||||
@ -987,7 +989,7 @@ func (scope *Scope) row() *sql.Row {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (scope *Scope) rows() (*sql.Rows, error) {
|
func (scope *Scope) rows() (*sql.Rows, error) {
|
||||||
defer scope.trace(scope.db.nowFunc())
|
defer scope.trace(NowFunc())
|
||||||
|
|
||||||
result := &RowsQueryResult{}
|
result := &RowsQueryResult{}
|
||||||
scope.InstanceSet("row_query_result", result)
|
scope.InstanceSet("row_query_result", result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user