]> gitweb.michael.orlitzky.com - mailshears.git/commitdiff
Flatten the SQL result set so that the array difference actually works.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 11 Feb 2010 00:49:50 +0000 (19:49 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 11 Feb 2010 00:49:50 +0000 (19:49 -0500)
Modified the SQL query to select only those accounts which are being delivered locally.

src/postfixadmin_db.rb

index e30c89c1bf982431043994602c0a2faa03dcd115..7998bfe677681638766b26a54275419b0a18d20f 100644 (file)
@@ -30,16 +30,21 @@ class PostfixadminDb
                                   @db_name,
                                   @db_user,
                                   @db_pass)
-      
-      sql_query = 'SELECT address FROM alias;'
+
+      # If address = goto, then the alias basically says, "really
+      # deliver to that address; it's not an alias."
+      sql_query = 'SELECT address FROM alias WHERE address = goto;'
       result = connection.query(sql_query)
       connection.close()
     rescue PGError => e
       # But pretend like we're database-agnostic in case we ever are.
       raise DatabaseError.new(e)
     end
-    
-    return result
+
+    # The database query returns an array of rows. Since we only asked
+    # for one column (address), we can flatten the result into an
+    # array of addresses.
+    return result.flatten
   end
   
 end