From fa696b0e2f84ee48dd9ce374edeec881a01aaa9a Mon Sep 17 00:00:00 2001 From: Femaref Date: Sun, 26 Apr 2015 16:34:52 +0200 Subject: [PATCH] Quote the primary column name when doing queries Postgresql requires certain column names to be quoted. When unquoted, all upper-case characters will be converted to lower-case, and column names like 'typeID' will result in a query on 'typeid'. --- callback_query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callback_query.go b/callback_query.go index 0eea6f89..825caac1 100644 --- a/callback_query.go +++ b/callback_query.go @@ -18,7 +18,7 @@ func Query(scope *Scope) { if orderBy, ok := scope.Get("gorm:order_by_primary_key"); ok { 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)) } }