6 #use Test::SQL::Translator;
10 use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants);
11 use Test::SQL::Translator qw(schema_ok);
13 # Simple options. -d for debug
15 BEGIN { map { $opt{$_}=1 if s/^-// } @ARGV; }
16 use constant DEBUG => (exists $opt{d} ? 1 : 0);
20 #=============================================================================
23 # maybe_plan(212, 'SQL::Translator::Parser::XML::SQLFairy');
26 my $testschema = "$Bin/data/xml/schema.xml";
27 open (my $testschema_fh, '<', $testschema) or die "$testschema: $!";
30 $sqlt = SQL::Translator->new({
35 die "Can't find test schema $testschema" unless -e $testschema;
40 local $SIG{__WARN__} = sub { push @w, $_[0] if $_[0] =~ /The database_event tag is deprecated - please use database_events/ };
42 $sql = $sqlt->translate(
45 data => do { local $/; <$testschema_fh> },
46 ) or die $sqlt->error;
49 ok (@w, 'database_event deprecation warning issued');
52 # Test the schema objs generted from the XML
54 my $scma = $sqlt->schema;
56 # Hmmm, when using schema_ok the field test data gets a bit too nested and
57 # fiddly to work with. (See 28xml-xmi-parser-sqlfairy.t for more a split out
63 options => [ { ENGINE => 'InnoDB' } ],
73 default_value => undef,
77 is_auto_increment => 1,
78 extra => { ZEROFILL => 1 },
82 data_type => "varchar",
84 default_value => "hello",
88 name => "description",
95 data_type => "varchar",
98 default_value => undef,
107 name => "explicitnulldef",
108 data_type => "varchar",
109 default_value => undef,
114 name => "explicitemptystring",
115 data_type => "varchar",
121 name => "emptytagdef",
122 data_type => "varchar",
125 comments => "Hello emptytagdef",
129 name => "another_id",
138 data_type => "timestamp",
154 name => 'emailuniqueindex',
160 fields => ["another_id"],
161 reference_table => "Another",
162 reference_fields => ["id"],
168 name => "titleindex",
185 options => [ { ENGINE => 'InnoDB' } ],
190 default_value => undef,
194 is_auto_increment => 1,
197 }, # end table Another
202 name => 'email_list',
203 sql => "SELECT email FROM Basic WHERE (email IS NOT NULL)",
215 name => 'foo_trigger',
216 perform_action_when => 'after',
217 database_events => 'insert',
219 action => 'update modified=timestamp();',
227 name => 'bar_trigger',
228 perform_action_when => 'before',
229 database_events => 'insert,update',
231 action => 'update modified2=timestamp();',
241 sql => 'select foo from bar',
242 parameters => ['foo', 'bar'],
244 comments => 'Go Sox!',