Added support to schema name in returning clause

This commit is contained in:
Marcelo Monaco 2015-09-07 17:47:15 -03:00
parent 447885d98f
commit 51213b0f69

View File

@ -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 {