* Add support for USING and WHERE on indexes in PostgreSQL producer
and parser (RT#63814, GH#52)
* Improve add_trigger consistency between producers (GH#48)
+ * Add trigger 'scope' attribute support to JSON, YAML and XML producers,
+ and XML and SQLite parsers (RT#119997)
* Declare dependencies in deterministic order (RT#102859)
* Multiple speedups of naive internal debugging mechanism (GH#54)
* Remove dependency on List::MoreUtils ( http://is.gd/lmu_cac_debacle )
database_events => $def->{'db_events'},
action => $def->{'action'},
on_table => $def->{'on_table'},
+ scope => 'row', # SQLite only supports row triggers
);
}
foreach (@nodes) {
my %data = get_tagfields($xp, $_, "sqlf:", qw/
name perform_action_when database_event database_events fields
- on_table action order extra
+ on_table action order extra scope
/);
# back compat
'fields' => scalar $trigger->fields,
'on_table' => scalar $trigger->on_table,
'action' => scalar $trigger->action,
+ 'scope' => scalar $trigger->scope,
keys %{$trigger->extra} ? ('extra' => { $trigger->extra } ) : (),
};
}
xml_obj_children( $xml, $schema,
tag => 'trigger',
methods => [qw/name database_events action on_table perform_action_when
- fields order extra/],
+ fields order extra scope/],
);
#
'fields' => scalar $trigger->fields,
'on_table' => scalar $trigger->on_table,
'action' => scalar $trigger->action,
+ 'scope' => scalar $trigger->scope,
keys %{$trigger->extra} ? ('extra' => { $trigger->extra } ) : (),
};
}
is( $obj->on_table, $test->{on_table},
"$t_name on_table is '$test->{on_table}'" );
+ is( $obj->scope, $test->{scope}, "$t_name scope is '$test->{scope}'" )
+ if exists $test->{scope};
+
is( $obj->action, $test->{action}, "$t_name action is '$test->{action}'" );
is_deeply( { $obj->extra }, $test->{extra}, "$t_name extra" );
#=============================================================================
BEGIN {
- maybe_plan(238, 'SQL::Translator::Parser::XML::SQLFairy');
+ maybe_plan(undef, 'SQL::Translator::Parser::XML::SQLFairy');
}
my $testschema = "$Bin/data/xml/schema.xml";
database_events => 'insert',
on_table => 'Basic',
action => 'update modified=timestamp();',
+ scope => 'row',
extra => {
foo => "bar",
hello => "world",
database_events => 'insert,update',
on_table => 'Basic',
action => 'update modified2=timestamp();',
+ scope => 'row',
extra => {
hello => "aliens",
},
],
}); # end schema
+
+done_testing;
</tables>
<views></views>
<triggers>
- <trigger name="foo_trigger" database_events="insert" on_table="Basic" perform_action_when="after" order="1">
+ <trigger name="foo_trigger" database_events="insert" on_table="Basic" perform_action_when="after" order="1" scope="row">
<action>update modified=timestamp();</action>
<extra hello="world" />
</trigger>
database_events => [$database_event],
table => $table,
action => $action,
+ scope => 'row',
extra => { hello => "world" },
) or die $s->error;
"name" : "pet_trig",
"on_table" : "pet",
"order" : "1",
- "perform_action_when" : "after"
+ "perform_action_when" : "after",
+ "scope": "row"
}
},
"views" : {
on_table: pet
order: 1
perform_action_when: after
+ scope: row
views:
person_pet:
fields: []
DROP TRIGGER IF EXISTS "foo_trigger";
-CREATE TRIGGER "foo_trigger" after insert ON "Basic" update modified=timestamp();;
+CREATE TRIGGER "foo_trigger" after insert ON "Basic" FOR EACH row update modified=timestamp();;
DROP TRIGGER IF EXISTS "bar_trigger";
-CREATE TRIGGER "bar_trigger" before insert OR update ON "Basic" update modified2=timestamp();;
+CREATE TRIGGER "bar_trigger" before insert OR update ON "Basic" FOR EACH row update modified2=timestamp();;
ALTER TABLE "Basic" ADD FOREIGN KEY ("another_id")
REFERENCES "Another" ("id") DEFERRABLE;
<triggers>
<trigger name="foo_trigger" database_event="insert" on_table="Basic"
- perform_action_when="after" order="1">
+ perform_action_when="after" order="1" scope="row">
<action>update modified=timestamp();</action>
<extra foo="bar" hello="world" bar="baz" />
</trigger>
<trigger name="bar_trigger" database_events="insert , update" on_table="Basic"
- perform_action_when="before" order="1">
+ perform_action_when="before" order="1" scope="row">
<action>update modified2=timestamp();</action>
<extra hello="aliens" />
</trigger>