Only output trigger 'scope' if it's set in YAML and JSON producers
Dagfinn Ilmari Mannsåker [Thu, 26 Jan 2017 18:28:05 +0000 (18:28 +0000)]
lib/SQL/Translator/Producer/JSON.pm
lib/SQL/Translator/Producer/YAML.pm

index d057d8e..b2f9004 100644 (file)
@@ -149,7 +149,9 @@ sub view_trigger {
         'fields'              => scalar $trigger->fields,
         'on_table'            => scalar $trigger->on_table,
         'action'              => scalar $trigger->action,
-        'scope'               => scalar $trigger->scope,
+        (defined $trigger->scope ? (
+            'scope'           => scalar $trigger->scope,
+        ) : ()),
         keys %{$trigger->extra} ? ('extra' => { $trigger->extra } ) : (),
     };
 }
index c5055ff..e7a8dc1 100644 (file)
@@ -148,7 +148,9 @@ sub view_trigger {
         'fields'              => scalar $trigger->fields,
         'on_table'            => scalar $trigger->on_table,
         'action'              => scalar $trigger->action,
-        'scope'               => scalar $trigger->scope,
+        (defined $trigger->scope ? (
+            'scope'           => scalar $trigger->scope,
+        ) : ()),
         keys %{$trigger->extra} ? ('extra' => { $trigger->extra } ) : (),
     };
 }