Merge pull request #2 from lunny/master

更新到最新版
This commit is contained in:
S.W.H 2014-03-22 19:41:08 +08:00
commit 7cdd448e31
3 changed files with 50 additions and 39 deletions

View File

@ -331,37 +331,45 @@ func update(engine *Engine, t *testing.T) {
panic(err) panic(err)
} }
cnt, err = engine.Insert(&Article{0, "1", "2", "3", "4", "5", 2}) defer func() {
if err != nil {
t.Error(err)
panic(err)
}
if cnt != 1 {
err = errors.New("insert not returned 1")
t.Error(err)
panic(err)
return
}
cnt, err = engine.Id(1).Update(&Article{Name: "6"})
if err != nil {
t.Error(err)
panic(err)
}
if cnt != 1 {
err = errors.New("update not returned 1")
t.Error(err)
panic(err)
return
}
err = engine.DropTables(&Article{}) err = engine.DropTables(&Article{})
if err != nil { if err != nil {
t.Error(err) t.Error(err)
panic(err) panic(err)
} }
}()
a := &Article{0, "1", "2", "3", "4", "5", 2}
cnt, err = engine.Insert(a)
if err != nil {
t.Error(err)
panic(err)
}
if cnt != 1 {
err = errors.New(fmt.Sprintf("insert not returned 1 but %d", cnt))
t.Error(err)
panic(err)
}
if a.Id == 0 {
err = errors.New("insert returned id is 0")
t.Error(err)
panic(err)
}
cnt, err = engine.Id(a.Id).Update(&Article{Name: "6"})
if err != nil {
t.Error(err)
panic(err)
}
if cnt != 1 {
err = errors.New(fmt.Sprintf("insert not returned 1 but %d", cnt))
t.Error(err)
panic(err)
return
}
} }
func updateSameMapper(engine *Engine, t *testing.T) { func updateSameMapper(engine *Engine, t *testing.T) {

View File

@ -681,6 +681,8 @@ if err != nil {
} }
``` ```
* 注意如果您使用的是mysql数据库引擎为innodb事务才有效myisam引擎是不支持事务的。
<a name="120" id="120"></a> <a name="120" id="120"></a>
## 11.缓存 ## 11.缓存

View File

@ -3,12 +3,6 @@ package main
import ( import (
"bytes" "bytes"
"fmt" "fmt"
_ "github.com/bylevel/pq"
"github.com/dvirsky/go-pylog/logging"
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
_ "github.com/ziutek/mymysql/godrv"
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
@ -16,6 +10,13 @@ import (
"strconv" "strconv"
"strings" //[SWH|+] "strings" //[SWH|+]
"text/template" "text/template"
"github.com/dvirsky/go-pylog/logging"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
_ "github.com/ziutek/mymysql/godrv"
) )
var CmdReverse = &Command{ var CmdReverse = &Command{