From b46ca62c1895f8ea8911d148809899e918ad6d96 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 11 Sep 2015 06:36:17 +0800 Subject: [PATCH] Fix ReturningStr when with schema name, fixes #650 --- callback_create.go | 4 ++-- foundation.go | 2 +- postgres.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/callback_create.go b/callback_create.go index bded5324..1bd8ff05 100644 --- a/callback_create.go +++ b/callback_create.go @@ -54,7 +54,7 @@ func Create(scope *Scope) { if len(columns) == 0 { scope.Raw(fmt.Sprintf("INSERT INTO %v DEFAULT VALUES %v", scope.QuotedTableName(), - scope.Dialect().ReturningStr(scope.TableName(), returningKey), + scope.Dialect().ReturningStr(scope.QuotedTableName(), returningKey), )) } else { scope.Raw(fmt.Sprintf( @@ -62,7 +62,7 @@ func Create(scope *Scope) { scope.QuotedTableName(), strings.Join(columns, ","), strings.Join(sqls, ","), - scope.Dialect().ReturningStr(scope.TableName(), returningKey), + scope.Dialect().ReturningStr(scope.QuotedTableName(), returningKey), )) } diff --git a/foundation.go b/foundation.go index 07968ad3..422fcc60 100644 --- a/foundation.go +++ b/foundation.go @@ -52,7 +52,7 @@ func (foundation) SqlTag(value reflect.Value, size int, autoIncrease bool) strin } func (s foundation) ReturningStr(tableName, key string) string { - return fmt.Sprintf("RETURNING %v.%v", s.Quote(tableName), key) + return fmt.Sprintf("RETURNING %v.%v", tableName, key) } func (s foundation) HasTable(scope *Scope, tableName string) bool { diff --git a/postgres.go b/postgres.go index 357f9842..db15b114 100644 --- a/postgres.go +++ b/postgres.go @@ -60,7 +60,7 @@ 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", tableName, key) } func (s postgres) HasTable(scope *Scope, tableName string) bool {