bug fixed

This commit is contained in:
Lunny Xiao 2013-11-15 11:01:13 +08:00
parent 74ec8ba9d2
commit 089ee96c19
2 changed files with 17 additions and 12 deletions

View File

@ -27,13 +27,9 @@ type SnakeMapper struct {
func snakeCasedName(name string) string {
newstr := make([]rune, 0)
firstTime := true
for _, chr := range name {
for idx, chr := range name {
if isUpper := 'A' <= chr && chr <= 'Z'; isUpper {
if firstTime == true {
firstTime = false
} else {
if idx > 0 {
newstr = append(newstr, '_')
}
chr -= ('A' - 'a')
@ -44,7 +40,7 @@ func snakeCasedName(name string) string {
return string(newstr)
}
func pascal2Sql(s string) (d string) {
/*func pascal2Sql(s string) (d string) {
d = ""
lastIdx := 0
for i := 0; i < len(s); i++ {
@ -61,7 +57,7 @@ func pascal2Sql(s string) (d string) {
}
d += s[lastIdx+1:]
return
}
}*/
func (mapper SnakeMapper) Obj2Table(name string) string {
return snakeCasedName(name)

View File

@ -1,7 +1,7 @@
package xorm
import (
"fmt"
//"fmt"
//_ "github.com/bylevel/pq"
_ "github.com/lib/pq"
"testing"
@ -20,6 +20,7 @@ func TestPostgres(t *testing.T) {
testAll2(engine, t)
}
/*
func TestPostgres2(t *testing.T) {
engine, err := NewEngine("postgres", "dbname=xorm_test sslmode=disable")
if err != nil {
@ -76,8 +77,6 @@ func TestPostgres2(t *testing.T) {
joinSameMapper(engine, t)
fmt.Println("-------------- havingSameMapper --------------")
havingSameMapper(engine, t)
fmt.Println("-------------- transaction --------------")
transaction(engine, t)
fmt.Println("-------------- combineTransactionSameMapper --------------")
combineTransactionSameMapper(engine, t)
fmt.Println("-------------- table --------------")
@ -106,7 +105,17 @@ func TestPostgres2(t *testing.T) {
testMetaInfo(engine, t)
fmt.Println("-------------- testIterate --------------")
testIterate(engine, t)
}
fmt.Println("-------------- testStrangeName --------------")
testStrangeName(engine, t)
fmt.Println("-------------- testVersion --------------")
testVersion(engine, t)
fmt.Println("-------------- testDistinct --------------")
testDistinct(engine, t)
fmt.Println("-------------- testUseBool --------------")
testUseBool(engine, t)
fmt.Println("-------------- transaction --------------")
transaction(engine, t)
}*/
func BenchmarkPostgresNoCache(t *testing.B) {
engine, err := NewEngine("postgres", "dbname=xorm_test sslmode=disable")