From: Michael Orlitzky Date: Thu, 11 Feb 2010 00:49:50 +0000 (-0500) Subject: Flatten the SQL result set so that the array difference actually works. X-Git-Tag: 0.0.1~152 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=7643bd3ebfe3d4aa8a56679c16e313ea9250f47e;p=mailshears.git Flatten the SQL result set so that the array difference actually works. Modified the SQL query to select only those accounts which are being delivered locally. --- diff --git a/src/postfixadmin_db.rb b/src/postfixadmin_db.rb index e30c89c..7998bfe 100644 --- a/src/postfixadmin_db.rb +++ b/src/postfixadmin_db.rb @@ -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