Commit | Line | Data |
8c4efd11 |
1 | #!/usr/bin/perl |
2 | use strict; |
3 | |
4 | use FindBin qw/$Bin/; |
5 | use Test::More; |
6 | use Test::SQL::Translator; |
7 | use Test::Exception; |
8 | use Data::Dumper; |
9 | use SQL::Translator; |
10 | use SQL::Translator::Schema::Constants; |
11 | |
12 | |
13 | BEGIN { |
14 | maybe_plan(1, 'SQL::Translator::Parser::XML::SQLFairy', |
15 | 'SQL::Translator::Producer::SQLite'); |
16 | } |
17 | |
18 | my $xmlfile = "$Bin/data/xml/schema.xml"; |
19 | |
20 | my $sqlt; |
21 | $sqlt = SQL::Translator->new( |
22 | no_comments => 1, |
23 | show_warnings => 1, |
24 | add_drop_table => 1, |
25 | ); |
26 | |
27 | die "Can't find test schema $xmlfile" unless -e $xmlfile; |
28 | |
29 | my $sql = $sqlt->translate( |
30 | from => 'XML-SQLFairy', |
31 | to => 'SQLite', |
32 | filename => $xmlfile, |
33 | ) or die $sqlt->error; |
34 | |
35 | # print ">>$sql<<\n"; |
36 | |
37 | is($sql, << "SQL"); |
38 | BEGIN TRANSACTION; |
39 | |
40 | |
8c4efd11 |
41 | DROP TABLE Basic; |
42 | CREATE TABLE Basic ( |
43 | id INTEGER PRIMARY KEY NOT NULL, |
44 | title varchar(100) NOT NULL DEFAULT 'hello', |
45 | description text DEFAULT '', |
46 | email varchar(255), |
47 | explicitnulldef varchar, |
48 | explicitemptystring varchar DEFAULT '', |
49 | -- Hello emptytagdef |
08d91aad |
50 | emptytagdef varchar DEFAULT '', |
b08b5416 |
51 | another_id int(10) DEFAULT '2', |
08d91aad |
52 | timest timestamp |
8c4efd11 |
53 | ); |
54 | |
55 | CREATE INDEX titleindex_Basic on Basic (title); |
56 | CREATE UNIQUE INDEX emailuniqueindex_Basic on Basic (email); |
57 | |
b08b5416 |
58 | DROP TABLE Another; |
59 | CREATE TABLE Another ( |
60 | id INTEGER PRIMARY KEY NOT NULL |
61 | ); |
62 | |
63 | |
8c4efd11 |
64 | COMMIT; |
65 | SQL |