forked from mirror/gorm
Quote table name when order by primary key
This commit is contained in:
parent
88858a942e
commit
facd84deec
|
@ -22,7 +22,7 @@ func Query(scope *Scope) {
|
||||||
|
|
||||||
if orderBy, ok := scope.InstanceGet("gorm:order_by_primary_key"); ok {
|
if orderBy, ok := scope.InstanceGet("gorm:order_by_primary_key"); ok {
|
||||||
if primaryKey := scope.PrimaryKey(); primaryKey != "" {
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue