mirror of https://github.com/go-gorm/gorm.git
Fix some errors for the mssql support pull request
This commit is contained in:
parent
a6b243a3e9
commit
5eeff5d38f
1
main.go
1
main.go
|
@ -119,7 +119,6 @@ func (s *DB) Limit(value interface{}) *DB {
|
||||||
|
|
||||||
func (s *DB) Offset(value interface{}) *DB {
|
func (s *DB) Offset(value interface{}) *DB {
|
||||||
return s.clone().search.offset(value).db
|
return s.clone().search.offset(value).db
|
||||||
return s.clone().search.offset(value).db
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DB) Order(value string, reorder ...bool) *DB {
|
func (s *DB) Order(value string, reorder ...bool) *DB {
|
||||||
|
|
14
main_test.go
14
main_test.go
|
@ -311,13 +311,11 @@ func TestRows(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
if rows != nil {
|
for rows.Next() {
|
||||||
for rows.Next() {
|
var name string
|
||||||
var name string
|
var age int64
|
||||||
var age int64
|
rows.Scan(&name, &age)
|
||||||
rows.Scan(&name, &age)
|
count++
|
||||||
count++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if count != 2 {
|
if count != 2 {
|
||||||
t.Errorf("Should found two records with name 3")
|
t.Errorf("Should found two records with name 3")
|
||||||
|
@ -452,7 +450,7 @@ func TestTimeWithZone(t *testing.T) {
|
||||||
name := "time_with_zone_" + strconv.Itoa(index)
|
name := "time_with_zone_" + strconv.Itoa(index)
|
||||||
user := User{Name: name, Birthday: vtime}
|
user := User{Name: name, Birthday: vtime}
|
||||||
|
|
||||||
//mssql does not support time zones
|
// TODO mssql does not support time zones
|
||||||
if dialect := os.Getenv("GORM_DIALECT"); dialect == "mssql" {
|
if dialect := os.Getenv("GORM_DIALECT"); dialect == "mssql" {
|
||||||
user.Birthday = vtime.UTC()
|
user.Birthday = vtime.UTC()
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,10 @@ package gorm_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/jinzhu/now"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/jinzhu/now"
|
||||||
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -239,11 +240,7 @@ func TestOrderAndPluck(t *testing.T) {
|
||||||
|
|
||||||
var ages []int64
|
var ages []int64
|
||||||
scopedb.Order("age desc").Pluck("age", &ages)
|
scopedb.Order("age desc").Pluck("age", &ages)
|
||||||
if ages != nil {
|
if ages[0] != 20 {
|
||||||
if ages[0] != 20 {
|
|
||||||
t.Errorf("The first age should be 20 when order with age desc")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
t.Errorf("The first age should be 20 when order with age desc")
|
t.Errorf("The first age should be 20 when order with age desc")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue