Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 99725
Status: resolved
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: NWELLNHOF [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.11021



Subject: PostgreSQL producer wrongly translates floating point types
The PostgreSQL producer translates types 'real' or 'float' to 'numeric' although the former is the preferred Postgres type for 32-bit floats and the latter is standard SQL. The 'float' conversion also has the problem that the 'size' value is interpreted differently for 'float' and 'numeric' (binary vs. decimal digits). The attached patch makes the following changes: - Don't translate 'real' and 'float' data types - Convert MySQL's 'double' to PostgreSQL's 'double precision' - Support size values for 'float' Reference: http://www.postgresql.org/docs/9.3/static/datatype-numeric.html
Subject: pg_numeric_types.patch
diff --git a/lib/SQL/Translator/Producer/PostgreSQL.pm b/lib/SQL/Translator/Producer/PostgreSQL.pm index 7fd7159..44b2cf7 100644 --- a/lib/SQL/Translator/Producer/PostgreSQL.pm +++ b/lib/SQL/Translator/Producer/PostgreSQL.pm @@ -43,9 +43,8 @@ BEGIN { # MySQL types # bigint => 'bigint', - double => 'numeric', + double => 'double precision', decimal => 'numeric', - float => 'numeric', int => 'integer', mediumint => 'integer', smallint => 'smallint', @@ -86,11 +85,9 @@ BEGIN { varchar => 'character varying', datetime => 'timestamp', text => 'text', - real => 'numeric', comment => 'text', bit => 'bit', tinyint => 'smallint', - float => 'numeric', ); $max_id_length = 62; @@ -733,7 +730,7 @@ sub convert_datatype my $type_with_size = join('|', 'bit', 'varbit', 'character', 'bit varying', 'character varying', - 'time', 'timestamp', 'interval', 'numeric' + 'time', 'timestamp', 'interval', 'numeric', 'float' ); if ( $data_type !~ /$type_with_size/ ) {
Thanks for the patch. It has been committed to git, and will be in the next release.