mirror of https://github.com/go-gorm/gorm.git
Fix quote table name with database
This commit is contained in:
parent
d22cd2e9d7
commit
0f08058713
9
scope.go
9
scope.go
|
@ -72,7 +72,16 @@ func (scope *Scope) SkipLeft() {
|
||||||
|
|
||||||
// Quote used to quote database column name according to database dialect
|
// Quote used to quote database column name according to database dialect
|
||||||
func (scope *Scope) Quote(str string) string {
|
func (scope *Scope) Quote(str string) string {
|
||||||
|
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)
|
return scope.Dialect().Quote(str)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dialect get dialect
|
// Dialect get dialect
|
||||||
|
|
Loading…
Reference in New Issue