From 21666494098acc8b575412678ad0704810d68092 Mon Sep 17 00:00:00 2001 From: Jay Taylor Date: Tue, 13 Jan 2015 15:27:35 -0800 Subject: [PATCH] Ensure identifiers are quoted for `RETURNING` and `DROP INDEX` statements. --- postgres.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postgres.go b/postgres.go index b2624448..218d594d 100644 --- a/postgres.go +++ b/postgres.go @@ -66,7 +66,7 @@ func (s *postgres) PrimaryKeyTag(value reflect.Value, size int) 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), s.Quote(key)) } func (s *postgres) SelectFromDummyTable() string { @@ -97,7 +97,7 @@ func (s *postgres) HasColumn(scope *Scope, tableName string, columnName 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{})