Remove unnecessary IsIgnored check

This commit is contained in:
Jinzhu 2015-01-23 08:59:05 +08:00
parent 930c7b80a1
commit e2c989be17
2 changed files with 2 additions and 2 deletions

View File

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

View File

@ -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()))
}