forked from mirror/gorm
Merge pull request #476 from Femaref/quote_columns
Quote the primary column name when doing queries
This commit is contained in:
commit
94643a48c1
|
@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue