Add a size/precision field to test file, make sure xml parser/producer work fine
Peter Rabbitson [Sat, 3 Oct 2009 17:57:32 +0000 (17:57 +0000)]
t/16xml-parser.t
t/17sqlfxml-producer.t
t/data/roundtrip.xml
t/data/xml/schema.xml

index 53180eb..ae96dd4 100644 (file)
@@ -27,7 +27,7 @@ use constant DEBUG => (exists $opt{d} ? 1 : 0);
 #=============================================================================
 
 BEGIN {
-    maybe_plan(212, 'SQL::Translator::Parser::XML::SQLFairy');
+    maybe_plan(224, 'SQL::Translator::Parser::XML::SQLFairy');
 }
 
 my $testschema = "$Bin/data/xml/schema.xml";
@@ -199,6 +199,12 @@ schema_ok( $scma, {
                     is_primary_key => 1,
                     is_auto_increment => 1,
                 },
+                {
+                    name => "num",
+                    data_type => "numeric",
+                    default_value => undef,
+                    size => '10,2',
+                },
             ],
         }, # end table Another
     ], # end tables
index 050bc42..5b9fa76 100644 (file)
@@ -297,6 +297,14 @@ $ans = <<EOXML;
           <extra ZEROFILL="1" />
           <comments></comments>
         </field>
+        <field name="bar" data_type="numeric" size="10,2" is_nullable="1" is_auto_increment="0" is_primary_key="0" is_foreign_key="0" order="2">
+          <extra />
+          <comments></comments>
+        </field>
+        <field name="baz" data_type="decimal" size="8,3" is_nullable="1" is_auto_increment="0" is_primary_key="0" is_foreign_key="0" order="3">
+          <extra />
+          <comments></comments>
+        </field>
       </fields>
       <indices></indices>
       <constraints></constraints>
@@ -326,6 +334,18 @@ EOXML
     ) or die $t->error;
     $f->extra(ZEROFILL => "1");
 
+    $t->add_field(
+        name      => "bar",
+        data_type => "numeric",
+        size      => "10,2",
+    ) or die $t->error;
+    $t->add_field(
+        name      => "baz",
+        data_type => "decimal",
+        size      => [8,3],
+    ) or die $t->error;
+
+
     # As we have created a Schema we give translate a dummy string so that
     # it will run the produce.
     lives_ok {$xml =$obj->translate("FOO");} "Translate (Field.extra) ran";
index db07e42..8630ee0 100644 (file)
@@ -39,6 +39,12 @@ Created on Fri Aug 15 15:08:18 2003
           <field name="timest" size="0"
               data_type="timestamp" order="7" >
           </field>
+          <field name="numeric" size="9,1"
+              data_type="numeric" order="8" >
+          </field>
+          <field name="decimal" size="10,2"
+              data_type="decimal" order="9" >
+          </field>
         </fields>
 
         <indices>
index 9949637..685ceff 100644 (file)
@@ -71,6 +71,11 @@ Created on Fri Aug 15 15:08:18 2003
               size="10" data_type="int" is_auto_increment="1" order="1"
               is_nullable="0">
           </field>
+          <field
+              name="num"
+              size="10,2" data_type="numeric" order="2"
+              is_nullable="1">
+          </field>
         </fields>
 
         <constraints>