mirror of https://github.com/go-gorm/gorm.git
Merge branch 'jaytaylor-postgres-quoting'
This commit is contained in:
commit
0d0e8d651d
|
@ -36,7 +36,7 @@ func Create(scope *Scope) {
|
||||||
|
|
||||||
returningKey := "*"
|
returningKey := "*"
|
||||||
if scope.PrimaryKey() != "" {
|
if scope.PrimaryKey() != "" {
|
||||||
returningKey = scope.PrimaryKey()
|
returningKey = scope.Quote(scope.PrimaryKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(columns) == 0 {
|
if len(columns) == 0 {
|
||||||
|
|
|
@ -4,8 +4,9 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/lib/pq/hstore"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/lib/pq/hstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type postgres struct {
|
type postgres struct {
|
||||||
|
@ -66,7 +67,7 @@ func (s *postgres) PrimaryKeyTag(value reflect.Value, size int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *postgres) ReturningStr(tableName, key string) string {
|
func (s *postgres) ReturningStr(tableName, key string) string {
|
||||||
return fmt.Sprintf("RETURNING \"%v\".%v", tableName, key)
|
return fmt.Sprintf("RETURNING %v.%v", s.Quote(tableName), key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *postgres) SelectFromDummyTable() string {
|
func (s *postgres) SelectFromDummyTable() string {
|
||||||
|
@ -97,7 +98,7 @@ func (s *postgres) HasColumn(scope *Scope, tableName string, columnName string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *postgres) RemoveIndex(scope *Scope, indexName string) {
|
func (s *postgres) RemoveIndex(scope *Scope, indexName string) {
|
||||||
scope.Raw(fmt.Sprintf("DROP INDEX %v", indexName)).Exec()
|
scope.Raw(fmt.Sprintf("DROP INDEX %v", s.Quote(indexName))).Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
var hstoreType = reflect.TypeOf(Hstore{})
|
var hstoreType = reflect.TypeOf(Hstore{})
|
||||||
|
|
Loading…
Reference in New Issue