From 64155294ca85bf12a3ee8f64dbf49ad0a04ccc11 Mon Sep 17 00:00:00 2001 From: yotamshacham Date: Thu, 20 Oct 2016 01:01:49 -0700 Subject: [PATCH] Fix to support period in DefaultTableNameHandler results. This is most definitely a hack, but its in place until we remove gorm completely during dm consolidation. --- postgres.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/postgres.go b/postgres.go index 4218e1ba..9498a5ab 100644 --- a/postgres.go +++ b/postgres.go @@ -60,7 +60,19 @@ 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) + return fmt.Sprintf("RETURNING %v.%v", s.quoteSplitPeriods(tableName), key) +} + +func (s postgres) quoteSplitPeriods(str string) string { + if strings.Index(str, ".") != -1 { + newStrs := []string{} + for _, str := range strings.Split(str, ".") { + newStrs = append(newStrs, s.Quote(str)) + } + return strings.Join(newStrs, ".") + } else { + return s.Quote(str) + } } func (postgres) HasTable(scope *Scope, tableName string) bool {