diff --git a/chain.go b/chain.go index 2c71ae5c..1ecef1bc 100644 --- a/chain.go +++ b/chain.go @@ -38,7 +38,7 @@ func (s *Chain) err(err error) error { } func (s *Chain) hasError() bool { - return len(s.Errors) > 0 + return s.Error != nil } func (s *Chain) deleteLastError() { diff --git a/do.go b/do.go index d70d2c5d..8b1f902e 100644 --- a/do.go +++ b/do.go @@ -302,14 +302,14 @@ func (s *Do) last() { } func (s *Do) getForeignKey(from *Model, to *Model, foreign_key string) (err error, from_from bool, foreign_value interface{}) { - if has_column, is_slice, value := from.ColumnAndValue(foreign_key); has_column { + if has_column, is_slice, value := from.columnAndValue(foreign_key); has_column { from_from = true if is_slice { foreign_value = to.primaryKeyValue() } else { foreign_value = value } - } else if has_column, _, _ := to.ColumnAndValue(foreign_key); has_column { + } else if has_column, _, _ := to.columnAndValue(foreign_key); has_column { foreign_value = from.primaryKeyValue() } else { err = errors.New("Can't find valid foreign Key") diff --git a/model.go b/model.go index da595d71..0003bd04 100644 --- a/model.go +++ b/model.go @@ -151,7 +151,7 @@ func (m *Model) hasColumn(name string) bool { return false } -func (m *Model) ColumnAndValue(name string) (has_column bool, is_slice bool, value interface{}) { +func (m *Model) columnAndValue(name string) (has_column bool, is_slice bool, value interface{}) { data := m.reflectData() if data.Kind() == reflect.Struct {