Merge pull request #476 from Femaref/quote_columns

Quote the primary column name when doing queries
This commit is contained in:
Jinzhu 2015-05-02 10:43:18 +08:00
commit 94643a48c1
1 changed files with 1 additions and 1 deletions

View File

@ -18,7 +18,7 @@ func Query(scope *Scope) {
if orderBy, ok := scope.Get("gorm:order_by_primary_key"); ok { if orderBy, ok := scope.Get("gorm:order_by_primary_key"); ok {
if primaryKey := scope.PrimaryKey(); primaryKey != "" { if primaryKey := scope.PrimaryKey(); primaryKey != "" {
scope.Search.Order(fmt.Sprintf("%v.%v %v", scope.QuotedTableName(), primaryKey, orderBy)) scope.Search.Order(fmt.Sprintf("%v.%v %v", scope.QuotedTableName(), scope.Quote(primaryKey), orderBy))
} }
} }