6 use Test::SQL::Translator;
11 use SQL::Translator::Schema::Constants;
15 maybe_plan(1, 'SQL::Translator::Parser::XML::SQLFairy',
16 'SQL::Translator::Producer::PostgreSQL');
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");
37 DROP TABLE "Basic" CASCADE;
38 CREATE TABLE "Basic" (
40 "title" character varying(100) DEFAULT 'hello' NOT NULL,
41 "description" text DEFAULT '',
42 "email" character varying(500),
43 "explicitnulldef" character varying,
44 "explicitemptystring" character varying DEFAULT '',
46 "emptytagdef" character varying DEFAULT '',
47 "another_id" integer DEFAULT 2,
50 CONSTRAINT "emailuniqueindex" UNIQUE ("email"),
51 CONSTRAINT "very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms" UNIQUE ("title")
53 CREATE INDEX "titleindex" on "Basic" ("title");
55 DROP TABLE "Another" CASCADE;
56 CREATE TABLE "Another" (
62 DROP VIEW "email_list";
63 CREATE VIEW "email_list" ( "email" ) AS
64 SELECT email FROM Basic WHERE (email IS NOT NULL)
67 DROP TRIGGER IF EXISTS "foo_trigger";
69 CREATE TRIGGER "foo_trigger" after insert ON "Basic" update modified=timestamp();;
71 DROP TRIGGER IF EXISTS "bar_trigger";
73 CREATE TRIGGER "bar_trigger" before insert OR update ON "Basic" update modified2=timestamp();;
75 ALTER TABLE "Basic" ADD FOREIGN KEY ("another_id")
76 REFERENCES "Another" ("id") DEFERRABLE;