bug fixed

This commit is contained in:
Lunny Xiao 2013-12-12 14:33:26 +08:00
parent bb6a9c24fa
commit 98d4c0e000
17 changed files with 5594 additions and 5558 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,9 @@ package main
import (
"fmt"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"os"
. "xorm"
)
type User struct {
@ -16,13 +16,13 @@ func main() {
f := "cache.db"
os.Remove(f)
Orm, err := NewEngine("sqlite3", f)
Orm, err := xorm.NewEngine("sqlite3", f)
if err != nil {
fmt.Println(err)
return
}
Orm.ShowSQL = true
cacher := NewLRUCacher(NewMemoryStore(), 1000)
cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 1000)
Orm.SetDefaultCacher(cacher)
err = Orm.CreateTables(&User{})

View File

@ -1,14 +1,11 @@
package main
import (
//xorm "github.com/lunny/xorm"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"os"
//"time"
//"sync/atomic"
xorm "xorm"
)
type User struct {
@ -40,36 +37,31 @@ func test(engine *xorm.Engine) {
for i := 0; i < size; i++ {
go func(x int) {
//x := i
err := engine.Test()
err := engine.Ping()
if err != nil {
fmt.Println(err)
} else {
err = engine.Map(u)
if err != nil {
fmt.Println("Map user failed")
} else {
for j := 0; j < 10; j++ {
if x+j < 2 {
_, err = engine.Get(u)
} else if x+j < 4 {
users := make([]User, 0)
err = engine.Find(&users)
} else if x+j < 8 {
_, err = engine.Count(u)
} else if x+j < 16 {
_, err = engine.Insert(&User{Name: "xlw"})
} else if x+j < 32 {
//_, err = engine.Id(1).Delete(u)
_, err = engine.Delete(u)
}
if err != nil {
fmt.Println(err)
queue <- x
return
}
for j := 0; j < 10; j++ {
if x+j < 2 {
_, err = engine.Get(u)
} else if x+j < 4 {
users := make([]User, 0)
err = engine.Find(&users)
} else if x+j < 8 {
_, err = engine.Count(u)
} else if x+j < 16 {
_, err = engine.Insert(&User{Name: "xlw"})
} else if x+j < 32 {
//_, err = engine.Id(1).Delete(u)
_, err = engine.Delete(u)
}
if err != nil {
fmt.Println(err)
queue <- x
return
}
fmt.Printf("%v success!\n", x)
}
fmt.Printf("%v success!\n", x)
}
queue <- x
}(i)

View File

@ -3,9 +3,9 @@ package main
import (
"errors"
"fmt"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"os"
. "xorm"
)
type Status struct {

View File

@ -2,9 +2,9 @@ package main
import (
"fmt"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"os"
. "xorm"
)
type User struct {

View File

@ -1,15 +1,12 @@
package main
import (
//xorm "github.com/lunny/xorm"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"os"
//"time"
//"sync/atomic"
"runtime"
xorm "xorm"
)
type User struct {

View File

@ -3,13 +3,11 @@ package main
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
xorm "github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"os"
//"time"
//"sync/atomic"
"runtime"
//xorm "xorm"
)
type User struct {

View File

@ -2,9 +2,9 @@ package main
import (
"fmt"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"os"
. "xorm"
)
type User struct {

View File

@ -2,9 +2,9 @@ package main
import (
"fmt"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"os"
. "xorm"
)
type User struct {

View File

@ -4,8 +4,8 @@ import (
"fmt"
_ "github.com/bylevel/pq"
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
"xorm"
)
type SyncUser2 struct {

View File

@ -1,8 +1,7 @@
package xorm
import (
//"reflect"
//"strings"
"strings"
)
// name translation between struct, fields names and table, column names
@ -71,6 +70,8 @@ func titleCasedName(name string) string {
newstr := make([]rune, 0)
upNextChar := true
name = strings.ToLower(name)
for _, chr := range name {
switch {
case upNextChar:

4483
session.go

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2
xorm/.gopmfile Normal file
View File

@ -0,0 +1,2 @@
[deps]
github.com/lunny/xorm=../

View File

@ -184,9 +184,9 @@ func genGoImports(tables []*xorm.Table) map[string]string {
func typestring(col *xorm.Column) string {
st := col.SQLType
if col.IsPrimaryKey {
/*if col.IsPrimaryKey {
return "int64"
}
}*/
t := xorm.SQLType2Type(st)
s := t.String()
if s == "[]uint8" {
@ -197,14 +197,16 @@ func typestring(col *xorm.Column) string {
func tag(table *xorm.Table, col *xorm.Column) string {
isNameId := (mapper.Table2Obj(col.Name) == "Id")
isIdPk := isNameId && typestring(col) == "int64"
res := make([]string, 0)
if !col.Nullable {
if !isNameId {
if !isIdPk {
res = append(res, "not null")
}
}
if col.IsPrimaryKey {
if !isNameId {
if !isIdPk {
res = append(res, "pk")
}
}
@ -212,7 +214,7 @@ func tag(table *xorm.Table, col *xorm.Column) string {
res = append(res, "default "+col.Default)
}
if col.IsAutoIncrement {
if !isNameId {
if !isIdPk {
res = append(res, "autoincr")
}
}

View File

@ -24,7 +24,7 @@ func init() {
var engine *xorm.Engine
func help() {
func shellHelp() {
fmt.Println(`
show tables show all tables
columns <table_name> show table's column info
@ -127,12 +127,12 @@ func runShell(cmd *Command, args []string) {
}
}
} else if lcmd == "show tables;" {
tables, err := engine.DBMetas()
if err != nil {
fmt.Println(err)
} else {
/*tables, err := engine.DBMetas()
if err != nil {
fmt.Println(err)
} else {
}
}*/
} else {
cnt, err := engine.Exec(scmd)
if err != nil {

View File

@ -18,6 +18,8 @@ import (
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
const go11tag = true
const version = "0.1"
// Commands lists the available commands and help topics.
// The order here is the order in which they are printed by 'gopm help'.
var commands = []*Command{
@ -70,7 +72,6 @@ func setExitStatus(n int) {
}
var usageTemplate = `xorm is a database tool based xorm package.
Usage:
xorm command [arguments]