From 0f08058713f16687703167d059edb6234f1985a4 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Tue, 24 Feb 2015 18:02:22 +0800 Subject: [PATCH] Fix quote table name with database --- scope.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scope.go b/scope.go index 181aceb5..bddf7472 100644 --- a/scope.go +++ b/scope.go @@ -72,7 +72,16 @@ func (scope *Scope) SkipLeft() { // Quote used to quote database column name according to database dialect func (scope *Scope) Quote(str string) string { - return scope.Dialect().Quote(str) + if strings.Index(str, ".") != -1 { + strs := strings.Split(str, ".") + newStrs := []string{} + for _, str := range strs { + newStrs = append(newStrs, scope.Dialect().Quote(str)) + } + return strings.Join(newStrs, ".") + } else { + return scope.Dialect().Quote(str) + } } // Dialect get dialect