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(284, 'SQL::Translator::Parser::XML::SQLFairy');
34 "$Bin/data/xml/schema-basic.xml",
35 "$Bin/data/xml/schema-basic-attribs.xml"
41 my $testschema = shift;
42 # Parse the test XML schema
44 $obj = SQL::Translator->new(
49 die "Can't find test schema $testschema" unless -e $testschema;
50 my $sql = $obj->translate(
51 from => 'XML-SQLFairy',
53 filename => $testschema,
57 # Test the schema objs generted from the XML
59 my $scma = $obj->schema;
61 # Hmmm, when using schema_ok the field test data gets a bit too nested and
62 # fiddly to work with. (See 28xml-xmi-parser-sqlfairy.t for more split out
72 default_value => undef,
76 is_auto_increment => 1,
80 data_type => "varchar",
82 default_value => "hello",
86 name => "description",
93 data_type => "varchar",
96 default_value => undef,
100 name => "explicitnulldef",
101 data_type => "varchar",
102 default_value => undef,
106 name => "explicitemptystring",
107 data_type => "varchar",
112 name => "emptytagdef",
113 data_type => "varchar",
124 name => 'emailuniqueindex',
131 name => "titleindex",
140 name => 'email_list',
141 sql => "SELECT email FROM Basic WHERE email IS NOT NULL",
148 name => 'foo_trigger',
149 perform_action_when => 'after',
150 database_event => 'insert',
152 action => 'update modified=timestamp();',
159 sql => 'select foo from bar',
160 parameters => ['foo', 'bar'],
162 comments => 'Go Sox!',