bug fixed
This commit is contained in:
parent
74ec8ba9d2
commit
089ee96c19
12
mapper.go
12
mapper.go
|
@ -27,13 +27,9 @@ type SnakeMapper struct {
|
||||||
|
|
||||||
func snakeCasedName(name string) string {
|
func snakeCasedName(name string) string {
|
||||||
newstr := make([]rune, 0)
|
newstr := make([]rune, 0)
|
||||||
firstTime := true
|
for idx, chr := range name {
|
||||||
|
|
||||||
for _, chr := range name {
|
|
||||||
if isUpper := 'A' <= chr && chr <= 'Z'; isUpper {
|
if isUpper := 'A' <= chr && chr <= 'Z'; isUpper {
|
||||||
if firstTime == true {
|
if idx > 0 {
|
||||||
firstTime = false
|
|
||||||
} else {
|
|
||||||
newstr = append(newstr, '_')
|
newstr = append(newstr, '_')
|
||||||
}
|
}
|
||||||
chr -= ('A' - 'a')
|
chr -= ('A' - 'a')
|
||||||
|
@ -44,7 +40,7 @@ func snakeCasedName(name string) string {
|
||||||
return string(newstr)
|
return string(newstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pascal2Sql(s string) (d string) {
|
/*func pascal2Sql(s string) (d string) {
|
||||||
d = ""
|
d = ""
|
||||||
lastIdx := 0
|
lastIdx := 0
|
||||||
for i := 0; i < len(s); i++ {
|
for i := 0; i < len(s); i++ {
|
||||||
|
@ -61,7 +57,7 @@ func pascal2Sql(s string) (d string) {
|
||||||
}
|
}
|
||||||
d += s[lastIdx+1:]
|
d += s[lastIdx+1:]
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
|
||||||
func (mapper SnakeMapper) Obj2Table(name string) string {
|
func (mapper SnakeMapper) Obj2Table(name string) string {
|
||||||
return snakeCasedName(name)
|
return snakeCasedName(name)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
//"fmt"
|
||||||
//_ "github.com/bylevel/pq"
|
//_ "github.com/bylevel/pq"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -20,6 +20,7 @@ func TestPostgres(t *testing.T) {
|
||||||
testAll2(engine, t)
|
testAll2(engine, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func TestPostgres2(t *testing.T) {
|
func TestPostgres2(t *testing.T) {
|
||||||
engine, err := NewEngine("postgres", "dbname=xorm_test sslmode=disable")
|
engine, err := NewEngine("postgres", "dbname=xorm_test sslmode=disable")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -76,8 +77,6 @@ func TestPostgres2(t *testing.T) {
|
||||||
joinSameMapper(engine, t)
|
joinSameMapper(engine, t)
|
||||||
fmt.Println("-------------- havingSameMapper --------------")
|
fmt.Println("-------------- havingSameMapper --------------")
|
||||||
havingSameMapper(engine, t)
|
havingSameMapper(engine, t)
|
||||||
fmt.Println("-------------- transaction --------------")
|
|
||||||
transaction(engine, t)
|
|
||||||
fmt.Println("-------------- combineTransactionSameMapper --------------")
|
fmt.Println("-------------- combineTransactionSameMapper --------------")
|
||||||
combineTransactionSameMapper(engine, t)
|
combineTransactionSameMapper(engine, t)
|
||||||
fmt.Println("-------------- table --------------")
|
fmt.Println("-------------- table --------------")
|
||||||
|
@ -106,7 +105,17 @@ func TestPostgres2(t *testing.T) {
|
||||||
testMetaInfo(engine, t)
|
testMetaInfo(engine, t)
|
||||||
fmt.Println("-------------- testIterate --------------")
|
fmt.Println("-------------- testIterate --------------")
|
||||||
testIterate(engine, t)
|
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) {
|
func BenchmarkPostgresNoCache(t *testing.B) {
|
||||||
engine, err := NewEngine("postgres", "dbname=xorm_test sslmode=disable")
|
engine, err := NewEngine("postgres", "dbname=xorm_test sslmode=disable")
|
||||||
|
|
Loading…
Reference in New Issue