]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/rm/plugins/roundcube.rb
lib,test: replace connection query() method with sync_exec{,_params}.
[mailshears.git] / lib / rm / plugins / roundcube.rb
index 88e88c42ab4a7683c18c246fefcc329572e1333a..56c3108c354cf79d0b5017e025d8e7c64fb75a5a 100644 (file)
@@ -27,16 +27,16 @@ class RoundcubeRm
 
     # Thanks to the ON DELETE triggers, this will remove all child
     # records associated with user_id too.
-    sql_queries = ['DELETE FROM users WHERE user_id = $1::int;']
+    sql_query = 'DELETE FROM users WHERE user_id = $1::int;'
 
-    connection = PGconn.connect(@db_host, @db_port, @db_opts, @db_tty,
-                                @db_name, @db_user, @db_pass)
+    connection = PG::Connection.new(@db_hash)
 
-    sql_queries.each do |sql_query|
-      connection.query(sql_query, [user_id])
+    begin
+      connection.sync_exec_params(sql_query, [user_id])
+    ensure
+      # Make sure the connection gets closed even if the query explodes.
+      connection.close()
     end
-
-    connection.close()
   end
 
 end