Fixed HasColumn, removed debug statements, improved test error messages
This commit is contained in:
parent
34a3fd2a3a
commit
6508b88f62
@ -2,7 +2,6 @@ package gorm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
@ -105,8 +104,9 @@ func (s cockroach) HasColumn(scope *Scope, tableName string, columnName string)
|
||||
}
|
||||
defer rows.Close()
|
||||
var column string
|
||||
var typ, null, defaultVal interface{}
|
||||
for rows.Next() {
|
||||
if err := rows.Scan(&column); err != nil {
|
||||
if err := rows.Scan(&column, &typ, &null, &defaultVal); err != nil {
|
||||
scope.Err(err)
|
||||
return false
|
||||
}
|
||||
@ -133,7 +133,6 @@ func (s cockroach) HasIndex(scope *Scope, tableName string, indexName string) bo
|
||||
scope.Err(err)
|
||||
return false
|
||||
}
|
||||
log.Printf("HasIndex %#v %#v %#v ", table, name, indexName)
|
||||
if name == indexName {
|
||||
return true
|
||||
}
|
||||
|
3
scope.go
3
scope.go
@ -4,7 +4,6 @@ import (
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
@ -362,8 +361,6 @@ func (scope *Scope) InstanceGet(name string) (interface{}, bool) {
|
||||
// Trace print sql log
|
||||
func (scope *Scope) Trace(t time.Time) {
|
||||
if len(scope.Sql) > 0 {
|
||||
// TODO(d4l3k): Remove this line
|
||||
log.Println("sql", scope.Sql, scope.SqlVars)
|
||||
scope.db.slog(scope.Sql, t, scope.SqlVars...)
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ func TestScannableSlices(t *testing.T) {
|
||||
}
|
||||
|
||||
if err := DB.Save(&r1).Error; err != nil {
|
||||
t.Errorf("Should save record with slice values")
|
||||
t.Errorf("Should save record with slice values; err %s", err)
|
||||
}
|
||||
|
||||
var r2 RecordWithSlice
|
||||
|
||||
if err := DB.Find(&r2).Error; err != nil {
|
||||
t.Errorf("Should fetch record with slice values")
|
||||
t.Errorf("Should fetch record with slice values; err %s", err)
|
||||
}
|
||||
|
||||
if len(r2.Strings) != 3 || r2.Strings[0] != "a" || r2.Strings[1] != "b" || r2.Strings[2] != "c" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user