4 # Before `make install' is performed this script should be runnable with
5 # `make test'. After `make install' it should work as `perl test.pl'
7 # Run script with -d for debug.
14 use Test::SQL::Translator;
18 use SQL::Translator::Schema::Constants;
20 # Simple options. -d for debug
22 BEGIN { map { $opt{$_}=1 if s/^-// } @ARGV; }
23 use constant DEBUG => (exists $opt{d} ? 1 : 0);
27 #=============================================================================
30 maybe_plan(204, 'SQL::Translator::Parser::XML::SQLFairy');
33 my $testschema = "$Bin/data/xml/schema.xml";
36 $sqlt = SQL::Translator->new(
41 die "Can't find test schema $testschema" unless -e $testschema;
42 my $sql = $sqlt->translate(
43 from => 'XML-SQLFairy',
45 filename => $testschema,
46 ) or die $sqlt->error;
49 # Test the schema objs generted from the XML
51 my $scma = $sqlt->schema;
53 # Hmmm, when using schema_ok the field test data gets a bit too nested and
54 # fiddly to work with. (See 28xml-xmi-parser-sqlfairy.t for more a split out
60 options => [ { ENGINE => 'InnoDB' } ],
70 default_value => undef,
74 is_auto_increment => 1,
75 extra => { ZEROFILL => 1 },
79 data_type => "varchar",
81 default_value => "hello",
85 name => "description",
92 data_type => "varchar",
95 default_value => undef,
104 name => "explicitnulldef",
105 data_type => "varchar",
106 default_value => undef,
111 name => "explicitemptystring",
112 data_type => "varchar",
118 name => "emptytagdef",
119 data_type => "varchar",
122 comments => "Hello emptytagdef",
126 name => "another_id",
135 data_type => "timestamp",
151 name => 'emailuniqueindex',
157 fields => ["another_id"],
158 reference_table => "Another",
159 reference_fields => ["id"],
165 name => "titleindex",
182 options => [ { ENGINE => 'InnoDB' } ],
187 default_value => undef,
191 is_auto_increment => 1,
194 }, # end table Another
199 name => 'email_list',
200 sql => "SELECT email FROM Basic WHERE email IS NOT NULL",
212 name => 'foo_trigger',
213 perform_action_when => 'after',
214 database_event => 'insert',
216 action => 'update modified=timestamp();',
228 sql => 'select foo from bar',
229 parameters => ['foo', 'bar'],
231 comments => 'Go Sox!',