package SQL::Translator::Parser::XML::SQLFairy;
# -------------------------------------------------------------------
-# $Id: SQLFairy.pm,v 1.13 2004-12-21 01:29:23 grommit Exp $
-# -------------------------------------------------------------------
# Copyright (C) 2003 Mark Addison <mark.addison@itn.co.uk>,
#
# This program is free software; you can redistribute it and/or
use strict;
use vars qw[ $DEBUG $VERSION @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/;
+$VERSION = '1.59';
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
+use Carp::Clan qw/^SQL::Translator/;
use Exporter;
use base qw(Exporter);
@EXPORT_OK = qw(parse);
foreach (@nodes) {
my %data = get_tagfields($xp, $_, "sqlf:",
qw/name type table fields reference_fields reference_table
- match_type on_delete_do on_update_do extra/
+ match_type on_delete on_update extra/
);
$table->add_constraint( %data ) or die $table->error;
}
$table->add_index( %data ) or die $table->error;
}
+
+ #
+ # Comments
+ #
+ @nodes = $xp->findnodes('sqlf:comments/sqlf:comment',$tblnode);
+ foreach (@nodes) {
+ my $data = $_->string_value;
+ $table->comments( $data );
+ }
+
} # tables loop
#
);
foreach (@nodes) {
my %data = get_tagfields($xp, $_, "sqlf:", qw/
- name perform_action_when database_event fields on_table action order
+ name perform_action_when database_event database_events fields on_table action order
extra
/);
+
+ # back compat
+ if (my $evt = $data{database_event} and $translator->{show_warnings}) {
+ carp 'The database_event tag is deprecated - please use database_events (which can take one or more comma separated event names)';
+ $data{database_events} = join (', ',
+ $data{database_events} || (),
+ $evt,
+ );
+ }
+
+ # split into arrayref
+ if (my $evts = $data{database_events}) {
+ $data{database_events} = [split (/\s*,\s*/, $evts) ];
+ }
+
$schema->add_trigger( %data ) or die $schema->error;
}