Add parenthesis into the VIEW definition to make sure the pg parser still can deal...
[dbsrgits/SQL-Translator.git] / t / 43xml-to-db2.t
index a8afc2f..02a7bfd 100644 (file)
@@ -4,12 +4,12 @@ use strict;
 use FindBin qw/$Bin/;
 use Test::More;
 use Test::SQL::Translator;
+use Test::Differences;
 use Test::Exception;
 use Data::Dumper;
 use SQL::Translator;
 use SQL::Translator::Schema::Constants;
 
-
 BEGIN {
     maybe_plan(1, 'SQL::Translator::Parser::XML::SQLFairy',
               'SQL::Translator::Producer::DB2');
@@ -20,7 +20,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,14 +32,14 @@ my $sql = $sqlt->translate(
     filename => $xmlfile,
 ) or die $sqlt->error;
 
-is($sql, << "SQL");
+eq_or_diff($sql, << "SQL");
 DROP TABLE Basic;
 
 CREATE TABLE Basic (
   id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL,
   title VARCHAR(100) NOT NULL DEFAULT 'hello',
   description VARCHAR(0) DEFAULT '',
-  email VARCHAR(255),
+  email VARCHAR(500),
   explicitnulldef VARCHAR(0),
   explicitemptystring VARCHAR(0) DEFAULT '',
   emptytagdef VARCHAR(0) DEFAULT '',
@@ -61,7 +61,9 @@ ALTER TABLE Basic ADD FOREIGN KEY (another_id) REFERENCES Another(id);
 CREATE INDEX titleindex ON Basic ( title );
 
 CREATE VIEW email_list AS
-SELECT email FROM Basic WHERE email IS NOT NULL;
+SELECT email FROM Basic WHERE (email IS NOT NULL);
 
 CREATE TRIGGER foo_trigger after insert ON Basic REFERENCING OLD AS oldrow NEW AS newrow FOR EACH ROW MODE DB2SQL update modified=timestamp();
+
+CREATE TRIGGER bar_trigger before insert, update ON Basic REFERENCING OLD AS oldrow NEW AS newrow FOR EACH ROW MODE DB2SQL update modified2=timestamp();
 SQL