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 #=============================================================================
32 "$Bin/data/xml/schema-basic.xml",
33 "$Bin/data/xml/schema-basic-attribs.xml"
39 my $testschema = shift;
40 # Parse the test XML schema
42 $obj = SQL::Translator->new(
47 die "Can't find test schema $testschema" unless -e $testschema;
48 my $sql = $obj->translate(
49 from => 'XML-SQLFairy',
51 filename => $testschema,
55 # Test the schema objs generted from the XML
57 my $scma = $obj->schema;
59 # Hmmm, when using schema_ok the field test data gets a bit too nested and
60 # fiddly to work with. (See 28xml-xmi-parser-sqlfairy.t for more split out
70 default_value => undef,
74 is_auto_increment => 1,
78 data_type => "varchar",
80 default_value => "hello",
84 name => "description",
91 data_type => "varchar",
94 default_value => undef,
98 name => "explicitnulldef",
99 data_type => "varchar",
100 default_value => undef,
104 name => "explicitemptystring",
105 data_type => "varchar",
110 name => "emptytagdef",
111 data_type => "varchar",
122 name => 'emailuniqueindex',
129 name => "titleindex",
138 name => 'email_list',
139 sql => "SELECT email FROM Basic WHERE email IS NOT NULL",
146 name => 'foo_trigger',
147 perform_action_when => 'after',
148 database_event => 'insert',
150 action => 'update modified=timestamp();',
157 sql => 'select foo from bar',
158 parameters => ['foo', 'bar'],
160 comments => 'Go Sox!',