Quote table name when order by primary key

This commit is contained in:
Jinzhu 2014-09-13 16:11:49 +08:00
parent 88858a942e
commit facd84deec
1 changed files with 1 additions and 1 deletions

View File

@ -22,7 +22,7 @@ func Query(scope *Scope) {
if orderBy, ok := scope.InstanceGet("gorm:order_by_primary_key"); ok {
if primaryKey := scope.PrimaryKey(); primaryKey != "" {
scope.Search = scope.Search.clone().order(fmt.Sprintf("%v.%v %v", scope.TableName(), primaryKey, orderBy))
scope.Search = scope.Search.clone().order(fmt.Sprintf("%v.%v %v", scope.QuotedTableName(), primaryKey, orderBy))
}
}