From e2c989be175910f994e4dc260608a2bf884b60fc Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 23 Jan 2015 08:59:05 +0800 Subject: [PATCH] Remove unnecessary IsIgnored check --- scope.go | 2 +- scope_private.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scope.go b/scope.go index f1c7e3ce..6a1c692e 100644 --- a/scope.go +++ b/scope.go @@ -444,7 +444,7 @@ func (scope *Scope) Fields(noRelations ...bool) map[string]*Field { if value, ok := fields[field.DBName]; ok { if value.IsIgnored { fields[field.DBName] = field - } else if !value.IsIgnored { + } else { panic(fmt.Sprintf("Duplicated column name for %v (%v)\n", scope.typeName(), fileWithLineNum())) } } else { diff --git a/scope_private.go b/scope_private.go index b3439c57..4c457355 100644 --- a/scope_private.go +++ b/scope_private.go @@ -300,7 +300,7 @@ func (s *Scope) joinsSql() string { func (scope *Scope) prepareQuerySql() { if scope.Search.Raw { - scope.Raw(strings.TrimRight(strings.TrimLeft(scope.CombinedConditionSql(), "WHERE ("), ")")) + scope.Raw(strings.TrimSuffix(strings.TrimPrefix(scope.CombinedConditionSql(), " WHERE ("), ")")) } else { scope.Raw(fmt.Sprintf("SELECT %v %v FROM %v %v", scope.topSql(), scope.selectSql(), scope.QuotedTableName(), scope.CombinedConditionSql())) }