Fix some errors for the mssql support pull request

This commit is contained in:
Jinzhu 2014-09-19 21:48:55 +08:00
parent a6b243a3e9
commit 5eeff5d38f
3 changed files with 9 additions and 15 deletions

View File

@ -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 {

View File

@ -311,14 +311,12 @@ 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()
} }

View File

@ -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,13 +240,9 @@ 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") 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")
}
var ages1, ages2 []int64 var ages1, ages2 []int64
scopedb.Order("age desc").Pluck("age", &ages1).Pluck("age", &ages2) scopedb.Order("age desc").Pluck("age", &ages1).Pluck("age", &ages2)