Add timestamp tests, make postgres produce timestamp(0) if asked
[dbsrgits/SQL-Translator.git] / t / 48xml-to-sqlite.t
CommitLineData
8c4efd11 1#!/usr/bin/perl
2use strict;
3
4use FindBin qw/$Bin/;
5use Test::More;
6use Test::SQL::Translator;
7use Test::Exception;
8use Data::Dumper;
9use SQL::Translator;
10use SQL::Translator::Schema::Constants;
11
12
13BEGIN {
14 maybe_plan(1, 'SQL::Translator::Parser::XML::SQLFairy',
15 'SQL::Translator::Producer::SQLite');
16}
17
18my $xmlfile = "$Bin/data/xml/schema.xml";
19
20my $sqlt;
21$sqlt = SQL::Translator->new(
22 no_comments => 1,
23 show_warnings => 1,
24 add_drop_table => 1,
25);
26
27die "Can't find test schema $xmlfile" unless -e $xmlfile;
28
29my $sql = $sqlt->translate(
30 from => 'XML-SQLFairy',
31 to => 'SQLite',
32 filename => $xmlfile,
33) or die $sqlt->error;
34
35# print ">>$sql<<\n";
36
37is($sql, << "SQL");
38BEGIN TRANSACTION;
39
40
41--
42-- Table: Basic
43--
44DROP TABLE Basic;
45CREATE 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
08d91aad 53 emptytagdef varchar DEFAULT '',
54 timest timestamp
8c4efd11 55);
56
57CREATE INDEX titleindex_Basic on Basic (title);
58CREATE UNIQUE INDEX emailuniqueindex_Basic on Basic (email);
59
60COMMIT;
61SQL