mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 18:00:55 +00:00
orm: Add test case for integer pk
This commit is contained in:
parent
a3d4218d9d
commit
84ae930c64
@ -387,6 +387,11 @@ func NewInLineOneToOne() *InLineOneToOne {
|
|||||||
return new(InLineOneToOne)
|
return new(InLineOneToOne)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IntegerPk struct {
|
||||||
|
Id int64 `orm:"pk"`
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
var DBARGS = struct {
|
var DBARGS = struct {
|
||||||
Driver string
|
Driver string
|
||||||
Source string
|
Source string
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -189,6 +190,7 @@ func TestSyncDb(t *testing.T) {
|
|||||||
RegisterModel(new(GroupPermissions))
|
RegisterModel(new(GroupPermissions))
|
||||||
RegisterModel(new(InLine))
|
RegisterModel(new(InLine))
|
||||||
RegisterModel(new(InLineOneToOne))
|
RegisterModel(new(InLineOneToOne))
|
||||||
|
RegisterModel(new(IntegerPk))
|
||||||
|
|
||||||
err := RunSyncdb("default", true, Debug)
|
err := RunSyncdb("default", true, Debug)
|
||||||
throwFail(t, err)
|
throwFail(t, err)
|
||||||
@ -210,6 +212,7 @@ func TestRegisterModels(t *testing.T) {
|
|||||||
RegisterModel(new(GroupPermissions))
|
RegisterModel(new(GroupPermissions))
|
||||||
RegisterModel(new(InLine))
|
RegisterModel(new(InLine))
|
||||||
RegisterModel(new(InLineOneToOne))
|
RegisterModel(new(InLineOneToOne))
|
||||||
|
RegisterModel(new(IntegerPk))
|
||||||
|
|
||||||
BootStrap()
|
BootStrap()
|
||||||
|
|
||||||
@ -1991,3 +1994,22 @@ func TestInLineOneToOne(t *testing.T) {
|
|||||||
throwFail(t, AssertIs(rinline.Name, name))
|
throwFail(t, AssertIs(rinline.Name, name))
|
||||||
throwFail(t, AssertIs(rinline.Email, email))
|
throwFail(t, AssertIs(rinline.Email, email))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIntegerPk(t *testing.T) {
|
||||||
|
its := []IntegerPk{
|
||||||
|
{Id: math.MinInt64, Value: "-"},
|
||||||
|
{Id: 0, Value: "0"},
|
||||||
|
{Id: math.MaxInt64, Value: "+"},
|
||||||
|
}
|
||||||
|
|
||||||
|
num, err := dORM.InsertMulti(len(its), its)
|
||||||
|
throwFail(t, err)
|
||||||
|
throwFail(t, AssertIs(num, len(its)))
|
||||||
|
|
||||||
|
for _, intPk := range its {
|
||||||
|
out := IntegerPk{Id: intPk.Id}
|
||||||
|
err = dORM.Read(&out)
|
||||||
|
throwFail(t, err)
|
||||||
|
throwFail(t, AssertIs(out.Value, intPk.Value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user