From: Peter Rabbitson Date: Sat, 3 Oct 2009 18:01:27 +0000 (+0000) Subject: Add numeric/decimal precision support to DB2 producer X-Git-Tag: v0.11008~79 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5ca2365add682f4c4e6589a25cebc359f00837db;p=dbsrgits%2FSQL-Translator.git Add numeric/decimal precision support to DB2 producer --- diff --git a/lib/SQL/Translator/Producer/DB2.pm b/lib/SQL/Translator/Producer/DB2.pm index a343674..0244546 100644 --- a/lib/SQL/Translator/Producer/DB2.pm +++ b/lib/SQL/Translator/Producer/DB2.pm @@ -306,7 +306,7 @@ sub create_field my $field_def = "$field_name $data_type"; $field_def .= $field->is_auto_increment ? ' GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1)' : ''; - $field_def .= $data_type =~ /(CHAR|CLOB)/i ? "(${size})" : ''; + $field_def .= $data_type =~ /(CHAR|CLOB|NUMERIC|DECIMAL)/i ? "(${size})" : ''; $field_def .= !$field->is_nullable ? ' NOT NULL':''; # $field_def .= $field->is_primary_key ? ' PRIMARY KEY':''; $field_def .= !defined $field->default_value ? '' : diff --git a/t/43xml-to-db2.t b/t/43xml-to-db2.t index 02a7bfd..a14a665 100644 --- a/t/43xml-to-db2.t +++ b/t/43xml-to-db2.t @@ -53,6 +53,7 @@ DROP TABLE Another; CREATE TABLE Another ( id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL, + num NUMERIC(10,2), PRIMARY KEY (id) ); diff --git a/t/44-xml-to-db2-array.t b/t/44-xml-to-db2-array.t index c09d850..d4f5a54 100644 --- a/t/44-xml-to-db2-array.t +++ b/t/44-xml-to-db2-array.t @@ -51,6 +51,7 @@ q|CREATE TABLE Basic ( q|CREATE TABLE Another ( id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) NOT NULL, + num NUMERIC(10,2), PRIMARY KEY (id) );|,