Fix RT49301
Peter Rabbitson [Sat, 3 Oct 2009 18:08:31 +0000 (18:08 +0000)]
lib/SQL/Translator/Producer/PostgreSQL.pm
t/46xml-to-pg.t
t/47postgres-producer.t

index ae37a83..b89c0d0 100644 (file)
@@ -702,7 +702,7 @@ sub convert_datatype
 
     my $type_with_size = join('|',
         'bit', 'varbit', 'character', 'bit varying', 'character varying',
-        'time', 'timestamp', 'interval'
+        'time', 'timestamp', 'interval', 'numeric'
     );
 
     if ( $data_type !~ /$type_with_size/ ) {
index dcdb01f..e1796df 100644 (file)
@@ -54,6 +54,7 @@ CREATE INDEX "titleindex" on "Basic" ("title");
 DROP TABLE "Another" CASCADE;
 CREATE TABLE "Another" (
   "id" serial NOT NULL,
+  "num" numeric(10,2),
   PRIMARY KEY ("id")
 );
 
index 55d3e17..ec31cd6 100644 (file)
@@ -14,7 +14,7 @@ use FindBin qw/$Bin/;
 #=============================================================================
 
 BEGIN {
-    maybe_plan(24,
+    maybe_plan(25,
         'SQL::Translator::Producer::PostgreSQL',
         'Test::Differences',
     )
@@ -113,6 +113,16 @@ is(
     'Create time field without time zone but with size, works'
 );
 
+my $field_num = SQL::Translator::Schema::Field->new( name => 'num',
+                                                  table => $table,
+                                                  data_type => 'numeric',
+                                                  size => [10,2],
+                                                  );
+my $fieldnum_sql = SQL::Translator::Producer::PostgreSQL::create_field($field_num);
+
+is($fieldnum_sql, 'num numeric(10,2)', 'Create numeric field works');
+
+
 my $field4 = SQL::Translator::Schema::Field->new( name      => 'bytea_field',
                                                   table => $table,
                                                   data_type => 'bytea',