diff options
Diffstat (limited to 'vendor/xorm.io/xorm/session_get.go')
-rw-r--r-- | vendor/xorm.io/xorm/session_get.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/vendor/xorm.io/xorm/session_get.go b/vendor/xorm.io/xorm/session_get.go index afedcd1f08..e303176d16 100644 --- a/vendor/xorm.io/xorm/session_get.go +++ b/vendor/xorm.io/xorm/session_get.go @@ -16,6 +16,11 @@ import ( "xorm.io/xorm/schemas" ) +var ( + // ErrObjectIsNil return error of object is nil + ErrObjectIsNil = errors.New("object should not be nil") +) + // Get retrieve one record from database, bean's non-empty fields // will be as conditions func (session *Session) Get(bean interface{}) (bool, error) { @@ -37,6 +42,8 @@ func (session *Session) get(bean interface{}) (bool, error) { return false, errors.New("needs a pointer to a value") } else if beanValue.Elem().Kind() == reflect.Ptr { return false, errors.New("a pointer to a pointer is not allowed") + } else if beanValue.IsNil() { + return false, ErrObjectIsNil } if beanValue.Elem().Kind() == reflect.Struct { |