From 51213b0f69d6495e00c40bfac78270e3594ed5c2 Mon Sep 17 00:00:00 2001 From: Marcelo Monaco Date: Mon, 7 Sep 2015 17:47:15 -0300 Subject: [PATCH] Added support to schema name in returning clause --- postgres.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/postgres.go b/postgres.go index 357f9842..49a9c4fe 100644 --- a/postgres.go +++ b/postgres.go @@ -5,6 +5,7 @@ import ( "database/sql/driver" "fmt" "reflect" + "strings" "time" "github.com/lib/pq/hstore" @@ -60,7 +61,12 @@ func (postgres) SqlTag(value reflect.Value, size int, autoIncrease bool) string } func (s postgres) ReturningStr(tableName, key string) string { - return fmt.Sprintf("RETURNING %v.%v", s.Quote(tableName), key) + fullName := strings.Split(tableName,".") + if len(fullName) == 1 { + return fmt.Sprintf("RETURNING %v.%v", s.Quote(tableName), key) + } else { + return fmt.Sprintf("RETURNING %v.%v.%v", s.Quote(fullName[0]), s.Quote(fullName[1]), key) + } } func (s postgres) HasTable(scope *Scope, tableName string) bool {