6 use Test::SQL::Translator;
11 use SQL::Translator::Schema::Constants;
15 maybe_plan(2, 'SQL::Translator::Parser::XML::SQLFairy',
16 'SQL::Translator::Producer::SQLite');
19 my $xmlfile = "$Bin/data/xml/schema.xml";
22 $sqlt = SQL::Translator->new(
28 die "Can't find test schema $xmlfile" unless -e $xmlfile;
30 my $sql = $sqlt->translate(
31 from => 'XML-SQLFairy',
34 ) or die $sqlt->error;
36 eq_or_diff($sql, << "SQL");
42 id INTEGER PRIMARY KEY NOT NULL,
43 title varchar(100) NOT NULL DEFAULT 'hello',
44 description text DEFAULT '',
46 explicitnulldef varchar,
47 explicitemptystring varchar DEFAULT '',
49 emptytagdef varchar DEFAULT '',
50 another_id int(10) DEFAULT '2',
54 CREATE INDEX titleindex_Basic ON Basic (title);
56 CREATE UNIQUE INDEX emailuniqueindex_Basic ON Basic (email);
60 CREATE TABLE Another (
61 id INTEGER PRIMARY KEY NOT NULL
64 DROP VIEW IF EXISTS email_list;
65 CREATE VIEW email_list AS
66 SELECT email FROM Basic WHERE email IS NOT NULL;
71 # Test in list context
72 my @sql = $sqlt->translate(
73 from => 'XML-SQLFairy',
76 ) or die $sqlt->error;
83 id INTEGER PRIMARY KEY NOT NULL,
84 title varchar(100) NOT NULL DEFAULT \'hello\',
85 description text DEFAULT \'\',
87 explicitnulldef varchar,
88 explicitemptystring varchar DEFAULT \'\',
90 emptytagdef varchar DEFAULT \'\',
91 another_id int(10) DEFAULT \'2\',
94 'CREATE INDEX titleindex_Basic02 ON Basic (title)',
95 'CREATE UNIQUE INDEX emailuniqueindex_Basic02 ON Basic (email)',
97 'CREATE TABLE Another (
98 id INTEGER PRIMARY KEY NOT NULL
100 'DROP VIEW IF EXISTS email_list;
101 CREATE VIEW email_list AS
102 SELECT email FROM Basic WHERE email IS NOT NULL',
104 ], 'SQLite translate in list context matches');