Fix test
This commit is contained in:
parent
b5c26997df
commit
dca8a72b64
|
@ -703,6 +703,13 @@ func (engine *Engine) AllCols() *Session {
|
||||||
return session.AllCols()
|
return session.AllCols()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load loads associated fields from database
|
||||||
|
func (engine *Engine) Load(beanOrSlices interface{}, cols ...string) error {
|
||||||
|
session := engine.NewSession()
|
||||||
|
session.isAutoClose = true
|
||||||
|
return session.Load(beanOrSlices, cols...)
|
||||||
|
}
|
||||||
|
|
||||||
// MustCols specify some columns must use even if they are empty
|
// MustCols specify some columns must use even if they are empty
|
||||||
func (engine *Engine) MustCols(columns ...string) *Session {
|
func (engine *Engine) MustCols(columns ...string) *Session {
|
||||||
session := engine.NewSession()
|
session := engine.NewSession()
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package xorm
|
package integrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
|
@ -11,16 +11,18 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExtendsTag(t *testing.T) {
|
func TestExtendsTag(t *testing.T) {
|
||||||
assert.NoError(t, prepareEngine())
|
assert.NoError(t, PrepareEngine())
|
||||||
|
|
||||||
table := testEngine.TableInfo(new(Userdetail))
|
table, err := testEngine.TableInfo(new(Userdetail))
|
||||||
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, table)
|
assert.NotNil(t, table)
|
||||||
assert.EqualValues(t, 3, len(table.ColumnsSeq()))
|
assert.EqualValues(t, 3, len(table.ColumnsSeq()))
|
||||||
assert.EqualValues(t, "id", table.ColumnsSeq()[0])
|
assert.EqualValues(t, "id", table.ColumnsSeq()[0])
|
||||||
assert.EqualValues(t, "intro", table.ColumnsSeq()[1])
|
assert.EqualValues(t, "intro", table.ColumnsSeq()[1])
|
||||||
assert.EqualValues(t, "profile", table.ColumnsSeq()[2])
|
assert.EqualValues(t, "profile", table.ColumnsSeq()[2])
|
||||||
|
|
||||||
table = testEngine.TableInfo(new(Userinfo))
|
table, err = testEngine.TableInfo(new(Userinfo))
|
||||||
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, table)
|
assert.NotNil(t, table)
|
||||||
assert.EqualValues(t, 8, len(table.ColumnsSeq()))
|
assert.EqualValues(t, 8, len(table.ColumnsSeq()))
|
||||||
assert.EqualValues(t, "id", table.ColumnsSeq()[0])
|
assert.EqualValues(t, "id", table.ColumnsSeq()[0])
|
||||||
|
@ -32,7 +34,8 @@ func TestExtendsTag(t *testing.T) {
|
||||||
assert.EqualValues(t, "avatar", table.ColumnsSeq()[6])
|
assert.EqualValues(t, "avatar", table.ColumnsSeq()[6])
|
||||||
assert.EqualValues(t, "is_man", table.ColumnsSeq()[7])
|
assert.EqualValues(t, "is_man", table.ColumnsSeq()[7])
|
||||||
|
|
||||||
table = testEngine.TableInfo(new(UserAndDetail))
|
table, err = testEngine.TableInfo(new(UserAndDetail))
|
||||||
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, table)
|
assert.NotNil(t, table)
|
||||||
assert.EqualValues(t, 11, len(table.ColumnsSeq()))
|
assert.EqualValues(t, 11, len(table.ColumnsSeq()))
|
||||||
assert.EqualValues(t, "id", table.ColumnsSeq()[0])
|
assert.EqualValues(t, "id", table.ColumnsSeq()[0])
|
||||||
|
|
|
@ -24,6 +24,7 @@ type Interface interface {
|
||||||
Alias(alias string) *Session
|
Alias(alias string) *Session
|
||||||
Asc(colNames ...string) *Session
|
Asc(colNames ...string) *Session
|
||||||
BufferSize(size int) *Session
|
BufferSize(size int) *Session
|
||||||
|
Cascade(trueOrFalse ...bool) *Session
|
||||||
Cols(columns ...string) *Session
|
Cols(columns ...string) *Session
|
||||||
Count(...interface{}) (int64, error)
|
Count(...interface{}) (int64, error)
|
||||||
CreateIndexes(bean interface{}) error
|
CreateIndexes(bean interface{}) error
|
||||||
|
@ -48,6 +49,7 @@ type Interface interface {
|
||||||
IsTableExist(beanOrTableName interface{}) (bool, error)
|
IsTableExist(beanOrTableName interface{}) (bool, error)
|
||||||
Iterate(interface{}, IterFunc) error
|
Iterate(interface{}, IterFunc) error
|
||||||
Limit(int, ...int) *Session
|
Limit(int, ...int) *Session
|
||||||
|
Load(beanOrSlices interface{}, cols ...string) error
|
||||||
MustCols(columns ...string) *Session
|
MustCols(columns ...string) *Session
|
||||||
NoAutoCondition(...bool) *Session
|
NoAutoCondition(...bool) *Session
|
||||||
NotIn(string, ...interface{}) *Session
|
NotIn(string, ...interface{}) *Session
|
||||||
|
|
Loading…
Reference in New Issue