package SQL::Translator::Schema::Trigger;
-# ----------------------------------------------------------------------
-# Copyright (C) 2002-2009 SQLFairy Authors
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; version 2.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-# 02111-1307 USA
-# -------------------------------------------------------------------
-
=pod
=head1 NAME
on_table => 'foo', # table name
action => '...', # text of trigger
schema => $schema, # Schema object
+ scope => 'row', # or statement
);
=head1 DESCRIPTION
=cut
use strict;
+use warnings;
use SQL::Translator::Utils 'parse_list_arg';
use base 'SQL::Translator::Schema::Object';
use Carp;
-use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
+our ( $TABLE_COUNT, $VIEW_COUNT );
-$VERSION = '1.59';
+our $VERSION = '1.59';
__PACKAGE__->_attributes( qw/
name schema perform_action_when database_events database_event
- fields table on_table action order
+ fields table on_table action order scope
/);
=pod
return $self->{'order'} || 0;
}
+
+sub scope {
+
+=pod
+
+=head2 scope
+
+Get or set the trigger's scope (row or statement).
+
+ my $scope = $trigger->scope('statement');
+
+=cut
+
+ my ( $self, $arg ) = @_;
+
+ if ( defined $arg ) {
+ return $self->error( "Invalid scope '$arg'" )
+ unless $arg =~ /^(row|statement)$/i;
+
+ $self->{scope} = $arg;
+ }
+
+ return $self->{scope} || '';
+}
+
sub schema {
=pod