X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F16xml-parser.t;h=53180eb695f58141d9146c14b494a18445ec0a46;hb=124b192cb3e01a3fe6441874c29918609d24de65;hp=bb9aecdcf9285a7187e69fbe9ee308f0bb8407bf;hpb=b08b5416f45bfbe381637ee3091202524c78ecab;p=dbsrgits%2FSQL-Translator.git diff --git a/t/16xml-parser.t b/t/16xml-parser.t index bb9aecd..53180eb 100644 --- a/t/16xml-parser.t +++ b/t/16xml-parser.t @@ -27,7 +27,7 @@ use constant DEBUG => (exists $opt{d} ? 1 : 0); #============================================================================= BEGIN { - maybe_plan(204, 'SQL::Translator::Parser::XML::SQLFairy'); + maybe_plan(212, 'SQL::Translator::Parser::XML::SQLFairy'); } my $testschema = "$Bin/data/xml/schema.xml"; @@ -39,12 +39,21 @@ $sqlt = SQL::Translator->new( add_drop_table => 1, ); die "Can't find test schema $testschema" unless -e $testschema; -my $sql = $sqlt->translate( + +my $sql; +{ + my @w; + local $SIG{__WARN__} = sub { push @w, $_[0] if $_[0] =~ /The database_event tag is deprecated - please use database_events/ }; + + $sql = $sqlt->translate( from => 'XML-SQLFairy', to => 'MySQL', filename => $testschema, -) or die $sqlt->error; -print $sql if DEBUG; + ) or die $sqlt->error; + print $sql if DEBUG; + + ok (@w, 'database_event deprecation warning issued'); +} # Test the schema objs generted from the XML # @@ -57,11 +66,11 @@ schema_ok( $scma, { tables => [ { name => "Basic", + options => [ { ENGINE => 'InnoDB' } ], extra => { foo => "bar", hello => "world", bar => "baz", - mysql_table_type => "InnoDB", }, fields => [ { @@ -90,7 +99,7 @@ schema_ok( $scma, { { name => "email", data_type => "varchar", - size => 255, + size => 500, is_unique => 1, default_value => undef, is_nullable => 1, @@ -105,12 +114,14 @@ schema_ok( $scma, { data_type => "varchar", default_value => undef, is_nullable => 1, + size => 255, }, { name => "explicitemptystring", data_type => "varchar", default_value => "", is_nullable => 1, + size => 255, }, { name => "emptytagdef", @@ -118,6 +129,7 @@ schema_ok( $scma, { default_value => "", is_nullable => 1, comments => "Hello emptytagdef", + size => 255, }, { name => "another_id", @@ -154,6 +166,7 @@ schema_ok( $scma, { fields => ["another_id"], reference_table => "Another", reference_fields => ["id"], + name => 'Basic_fk' }, ], indices => [ @@ -174,8 +187,8 @@ schema_ok( $scma, { foo => "bar", hello => "world", bar => "baz", - mysql_table_type => "InnoDB", }, + options => [ { ENGINE => 'InnoDB' } ], fields => [ { name => "id", @@ -193,7 +206,7 @@ schema_ok( $scma, { views => [ { name => 'email_list', - sql => "SELECT email FROM Basic WHERE email IS NOT NULL", + sql => "SELECT email FROM Basic WHERE (email IS NOT NULL)", fields => ['email'], extra => { foo => "bar", @@ -207,7 +220,7 @@ schema_ok( $scma, { { name => 'foo_trigger', perform_action_when => 'after', - database_event => 'insert', + database_events => 'insert', on_table => 'Basic', action => 'update modified=timestamp();', extra => { @@ -216,6 +229,16 @@ schema_ok( $scma, { bar => "baz", }, }, + { + name => 'bar_trigger', + perform_action_when => 'before', + database_events => 'insert,update', + on_table => 'Basic', + action => 'update modified2=timestamp();', + extra => { + hello => "aliens", + }, + }, ], procedures => [