Improve xml database_event deprecation warning
[dbsrgits/SQL-Translator.git] / t / 46xml-to-pg.t
index 7bb025f..c38d917 100644 (file)
@@ -5,6 +5,7 @@ use FindBin qw/$Bin/;
 use Test::More;
 use Test::SQL::Translator;
 use Test::Exception;
+use Test::Differences;
 use Data::Dumper;
 use SQL::Translator;
 use SQL::Translator::Schema::Constants;
@@ -20,7 +21,7 @@ my $xmlfile = "$Bin/data/xml/schema.xml";
 my $sqlt;
 $sqlt = SQL::Translator->new(
     no_comments => 1,
-    show_warnings  => 1,
+    show_warnings  => 0,
     add_drop_table => 1,
 );
 
@@ -32,8 +33,8 @@ my $sql = $sqlt->translate(
     filename => $xmlfile,
 ) or die $sqlt->error;
 
-is($sql, << "SQL");
-DROP TABLE "Basic";
+eq_or_diff($sql, << "SQL");
+DROP TABLE "Basic" CASCADE;
 CREATE TABLE "Basic" (
   "id" serial NOT NULL,
   "title" character varying(100) DEFAULT 'hello' NOT NULL,
@@ -43,9 +44,25 @@ CREATE TABLE "Basic" (
   "explicitemptystring" character varying DEFAULT '',
   -- Hello emptytagdef
   "emptytagdef" character varying DEFAULT '',
+  "another_id" integer DEFAULT '2',
   "timest" timestamp(0),
   PRIMARY KEY ("id"),
-  Constraint "emailuniqueindex" UNIQUE ("email")
+  CONSTRAINT "emailuniqueindex" UNIQUE ("email")
 );
 CREATE INDEX "titleindex" on "Basic" ("title");
+
+DROP TABLE "Another" CASCADE;
+CREATE TABLE "Another" (
+  "id" serial NOT NULL,
+  PRIMARY KEY ("id")
+);
+
+DROP VIEW "email_list";
+CREATE VIEW "email_list" ( "email" ) AS (
+    SELECT email FROM Basic WHERE email IS NOT NULL
+  );
+
+ALTER TABLE "Basic" ADD FOREIGN KEY ("another_id")
+  REFERENCES "Another" ("id") DEFERRABLE;
+
 SQL