Clean up the customcode SQL so it no longer errors out when no matching goat-level...
authorGreg Sabino Mullane <greg@endpoint.com>
Sun, 4 Nov 2012 03:39:32 +0000 (23:39 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Sun, 4 Nov 2012 03:39:32 +0000 (23:39 -0400)
Bucardo.pm

index 51569a4e549ef99fd6b9a5e2a46b847d90e69929..640060888d9352cc64a3cae68edb600ee7a77354 100644 (file)
@@ -5627,13 +5627,14 @@ sub validate_sync {
 
     ## Validate all (active) custom codes for this sync
     my $goatlistcodes = join ',' => map { $_->{id} } @{$s->{goatlist}};
+    my $goatclause = length $goatlistcodes ? "OR m.goat IN ($goatlistcodes)" : '';
 
     $SQL = qq{
             SELECT c.src_code, c.id, c.whenrun, c.getdbh, c.name, COALESCE(c.about,'?') AS about,
                    c.trigrules, m.active, m.priority, COALESCE(m.goat,0) AS goat
             FROM customcode c, customcode_map m
             WHERE c.id=m.code AND m.active IS TRUE
-            AND (m.sync = ? OR m.goat IN ($goatlistcodes))
+            AND (m.sync = ? $goatclause)
             ORDER BY priority ASC
         };
     $sth = $self->{masterdbh}->prepare($SQL);