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::PostgreSQL'); |
16 | } |
17 | |
18 | my $xmlfile = "$Bin/data/xml/samefield.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 => 'PostgreSQL', |
32 | filename => $xmlfile, |
33 | ) or die $sqlt->error; |
34 | |
35 | is($sql, << "SQL"); |
cc00c034 |
36 | DROP TABLE "one" CASCADE; |
8c4efd11 |
37 | CREATE TABLE "one" ( |
38 | "same" character varying(100) DEFAULT 'hello' NOT NULL |
39 | ); |
40 | |
cc00c034 |
41 | DROP TABLE "two" CASCADE; |
8c4efd11 |
42 | CREATE TABLE "two" ( |
43 | "same" character varying(100) DEFAULT 'hello' NOT NULL |
44 | ); |
45 | |
46 | SQL |
47 | |
48 | ### This doesnt work, cant add a field with a name thats already there, so how do we test dupe field names?! |
49 | |
50 | # my $table = $sqlt->schema->get_table('two'); |
51 | # $table->add_field(name => 'same'); |
52 | # print Dumper($table); |
53 | # $sql = SQL::Translator::Producer::PostgreSQL::produce($sqlt); |
54 | # print ">>$sql<<\n"; |