patch from abraxxa (Alexander Hartmaier) to truncate unique constraint names that...
[dbsrgits/SQL-Translator.git] / t / 18ttschema-producer.t
index d4c1e93..909a015 100644 (file)
@@ -16,14 +16,9 @@ use FindBin qw/$Bin/;
 #=============================================================================
 
 BEGIN {
-    eval {require Template;};
-        plan skip_all => "Template v2.15 is is incompatible with SQL::Translator 0.08+" 
-        if !$@ && Template->VERSION >= 2.15;
-
-    maybe_plan(6, 
-        'XML::XPath', 
+    maybe_plan(6,
         'SQL::Translator::Parser::XML::SQLFairy',
-        'Template', 
+        'Template 2.20',
         'Test::Differences'
     );
 }
@@ -36,13 +31,12 @@ use SQL::Translator::Producer::TTSchema;
 {
     my $obj;
     $obj = SQL::Translator->new(
-        show_warnings  => 1,
+        show_warnings  => 0,
         from           => "XML-SQLFairy",
         filename       => "$Bin/data/xml/schema.xml",
         to             => "TTSchema",
         producer_args  => {
             ttfile  => "$Bin/data/template/basic.tt",
-#            ttfile  => "$Bin/data/template/test.tt",
             tt_vars => {
                 foo   => 'bar',
                 hello => 'world',
@@ -51,7 +45,6 @@ use SQL::Translator::Producer::TTSchema;
     );
     my $out;
     lives_ok { $out = $obj->translate; }  "Translate ran";
-#    print STDERR "Output: $out\n";
     ok $out ne ""                        ,"Produced something!";
     local $/ = undef; # slurp
     eq_or_diff $out, <DATA>              ,"Output looks right";
@@ -65,7 +58,7 @@ use SQL::Translator::Producer::TTSchema;
     [%- END %]};
     my $obj;
     $obj = SQL::Translator->new(
-        show_warnings  => 1,
+        show_warnings  => 0,
         from           => "XML-SQLFairy",
         filename       => "$Bin/data/xml/schema.xml",
         to             => "TTSchema",
@@ -122,7 +115,7 @@ Fields
         is_nullable:           0
         default_value:         hello
         is_primary_key:        0
-        is_unique:             0
+        is_unique:             1
         is_auto_increment:     0
         is_foreign_key:        0
         foreign_key_reference: 
@@ -146,7 +139,7 @@ Fields
     
     email
         data_type:             varchar
-        size:                  255
+        size:                  500
         is_nullable:           1
         default_value:         
         is_primary_key:        0
@@ -265,6 +258,19 @@ Constraints
         options:          
         is_valid:         1
     
+    very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms
+        type:             UNIQUE
+        fields:           title
+        expression:       
+        match_type:       
+        reference_fields: 
+        reference_table:  
+        deferrable:       1
+        on_delete:        
+        on_update:        
+        options:          
+        is_valid:         1
+    
     ?
         type:             FOREIGN KEY
         fields:           another_id
@@ -293,7 +299,21 @@ Fields
         is_foreign_key:        0
         foreign_key_reference: 
         is_valid:              1
-        order:                 10
+        order:                 1
+        table:                 Another
+    
+    num
+        data_type:             numeric
+        size:                  10,2
+        is_nullable:           1
+        default_value:         
+        is_primary_key:        0
+        is_unique:             0
+        is_auto_increment:     0
+        is_foreign_key:        0
+        foreign_key_reference: 
+        is_valid:              1
+        order:                 2
         table:                 Another