@@ -158,7 +158,7 @@ func setPubOwner(txn *sql.Tx, d *schema.ResourceData) error {
158
158
n := nraw .(string )
159
159
pubName := d .Get (pubNameAttr ).(string )
160
160
161
- sql := fmt .Sprintf ("ALTER PUBLICATION %s OWNER TO %s" , pubName , n )
161
+ sql := fmt .Sprintf ("ALTER PUBLICATION %s OWNER TO %s" , pq . QuoteIdentifier ( pubName ) , n )
162
162
if _ , err := txn .Exec (sql ); err != nil {
163
163
return fmt .Errorf ("Error updating publication owner: %w" , err )
164
164
}
@@ -183,12 +183,12 @@ func setPubTables(txn *sql.Tx, d *schema.ResourceData) error {
183
183
added := arrayDifference (newList , oldList )
184
184
185
185
for _ , p := range added {
186
- query := fmt .Sprintf ("ALTER PUBLICATION %s ADD TABLE %s" , pubName , quoteTableName (p .(string )))
186
+ query := fmt .Sprintf ("ALTER PUBLICATION %s ADD TABLE %s" , pq . QuoteIdentifier ( pubName ) , quoteTableName (p .(string )))
187
187
queries = append (queries , query )
188
188
}
189
189
190
190
for _ , p := range dropped {
191
- query := fmt .Sprintf ("ALTER PUBLICATION %s DROP TABLE %s" , pubName , quoteTableName (p .(string )))
191
+ query := fmt .Sprintf ("ALTER PUBLICATION %s DROP TABLE %s" , pq . QuoteIdentifier ( pubName ) , quoteTableName (p .(string )))
192
192
queries = append (queries , query )
193
193
}
194
194
@@ -202,13 +202,12 @@ func setPubTables(txn *sql.Tx, d *schema.ResourceData) error {
202
202
203
203
func setPubParams (txn * sql.Tx , d * schema.ResourceData , pubViaRootEnabled bool ) error {
204
204
pubName := d .Get (pubNameAttr ).(string )
205
- paramAlterTemplate := "ALTER PUBLICATION %s %s"
206
205
publicationParametersString , err := getPublicationParameters (d , pubViaRootEnabled )
207
206
if err != nil {
208
207
return fmt .Errorf ("Error getting publication parameters: %w" , err )
209
208
}
210
209
if publicationParametersString != "" {
211
- sql := fmt .Sprintf (paramAlterTemplate , pubName , publicationParametersString )
210
+ sql := fmt .Sprintf ("ALTER PUBLICATION %s %s" , pq . QuoteIdentifier ( pubName ) , publicationParametersString )
212
211
if _ , err := txn .Exec (sql ); err != nil {
213
212
return fmt .Errorf ("Error updating publication parameters: %w" , err )
214
213
}
@@ -240,7 +239,7 @@ func resourcePostgreSQLPublicationCreate(db *DBConnection, d *schema.ResourceDat
240
239
}
241
240
defer deferredRollback (txn )
242
241
243
- sql := fmt .Sprintf ("CREATE PUBLICATION %s %s %s" , name , tables , publicationParameters )
242
+ sql := fmt .Sprintf ("CREATE PUBLICATION %s %s %s" , pq . QuoteIdentifier ( name ) , tables , publicationParameters )
244
243
245
244
if _ , err := txn .Exec (sql ); err != nil {
246
245
return fmt .Errorf ("Error creating Publication: %w" , err )
0 commit comments