Add timestamp tests, make postgres produce timestamp(0) if asked
[dbsrgits/SQL-Translator.git] / t / 48xml-to-sqlite.t
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
41 --
42 -- Table: Basic
43 --
44 DROP TABLE Basic;
45 CREATE TABLE Basic (
46   id INTEGER PRIMARY KEY NOT NULL,
47   title varchar(100) NOT NULL DEFAULT 'hello',
48   description text DEFAULT '',
49   email varchar(255),
50   explicitnulldef varchar,
51   explicitemptystring varchar DEFAULT '',
52   -- Hello emptytagdef
53   emptytagdef varchar DEFAULT '',
54   timest timestamp
55 );
56
57 CREATE INDEX titleindex_Basic on Basic (title);
58 CREATE UNIQUE INDEX emailuniqueindex_Basic on Basic (email);
59
60 COMMIT;
61 SQL