lib,test: replace connection query() method with sync_exec{,_params}.
[mailshears.git] / lib / common / roundcube_plugin.rb
index a4300c4a016bcd8f85d6177edd76f1ee51378426..6d522bb371847e433906af3792f74545916bd7cc 100644 (file)
@@ -47,12 +47,12 @@ module RoundcubePlugin
   def list_users()
     usernames = []
 
-    connection = PG::Connection.connect(@db_hash)
+    connection = PG::Connection.new(@db_hash)
 
     sql_query = 'SELECT username FROM users;'
 
     begin
-      connection.query(sql_query) do |result|
+      connection.sync_exec(sql_query) do |result|
         usernames = result.field_values('username')
       end
     ensure
@@ -79,7 +79,7 @@ module RoundcubePlugin
     sql_query = 'SELECT user_id FROM users WHERE username = $1;'
 
     begin
-      connection.query(sql_query, [user.to_s()]) do |result|
+      connection.sync_exec_params(sql_query, [user.to_s()]) do |result|
         if result.num_tuples > 0
           user_id = result[0]['user_id']
         end