for my $trigger ( $schema->get_triggers ) {
push @table_defs, create_trigger( $trigger, {
add_drop_trigger => $add_drop_table,
+ generator => $generator,
no_comments => $no_comments,
});
}
sub create_trigger {
my ($trigger,$options) = @_;
+ my $generator = _generator($options);
my @statements;
- push @statements, sprintf( 'DROP TRIGGER IF EXISTS %s', $trigger->name )
+ push @statements, sprintf( 'DROP TRIGGER IF EXISTS %s', $generator->quote($trigger->name) )
if $options->{add_drop_trigger};
my $scope = $trigger->scope || '';
push @statements, sprintf(
'CREATE TRIGGER %s %s %s ON %s%s %s',
- $trigger->name,
+ $generator->quote($trigger->name),
$trigger->perform_action_when,
join( ' OR ', @{ $trigger->database_events } ),
- $trigger->on_table,
+ $generator->quote($trigger->on_table),
$scope,
$trigger->action,
);
SELECT email FROM Basic WHERE (email IS NOT NULL)
;
-DROP TRIGGER IF EXISTS foo_trigger;
+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" update modified=timestamp();;
-DROP TRIGGER IF EXISTS bar_trigger;
+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" update modified2=timestamp();;
ALTER TABLE "Basic" ADD FOREIGN KEY ("another_id")
REFERENCES "Another" ("id") DEFERRABLE;
<action>update modified2=timestamp();</action>
<extra hello="aliens" />
</trigger>
+ <trigger name="`trigger` [with] "quotes""
+ database_events="insert"
+ on_table="`table` [with] "quotes""
+ perform_action_when="before" order="1">
+ <action>select timestamp();</action>
+ </trigger>
</triggers>
<procedures>