Skip Menu |

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

Report information
The Basics
Id: 42548
Status: resolved
Worked: 10 min
Priority: 0/
Queue: SQL-Translator

People
Owner: kclark [...] cpan.org
Requestors: ddascalescu+perl [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.09002
Fixed in: (no value)



Subject: Producer::PostgreSQL incorrectly inserts the size in 'time(stamp)? with(out) time zone' fields
For fields of the type time(stamp) with or without time zone, SQL::Translator::Producer::PostgreSQL::convert_datatype() outputs the size in parentheses at the end of the field: timestamp with time zone(6) or time without time zone(4) This is, however, incorrect, per the documentation at http://www.postgresql.org/docs/current/interactive/datatype-datetime.html The attached patch inserts the size correctly (before "with"). Test cases included. HTH, Dan Dascalescu
Subject: PostgreSQL.diff
708,710c708,712 < < if ( defined $size[0] && $size[0] > 0 ) { < $data_type .= '(' . join( ',', @size ) . ')'; --- > > # The size must be inserted before "with(out) time zone), per > # http://www.postgresql.org/docs/current/interactive/datatype-datetime.html > if ( defined $size[0] && $data_type =~ /^time(stamp)?\s+with/ ) { > $data_type =~ s/(time(?:stamp)?)/$1 . '(' . join( ',', @size ) . ')'/e; 712c714 < elsif (defined $size[0] && $data_type eq 'timestamp' ) { --- > elsif ( defined $size[0] && $size[0] > 0 ) {
Subject: 47postgres-producer.diff
17c17 < maybe_plan(13, --- > maybe_plan(15, 78a79,100 > > > my $field3_datetime_with_TZ = SQL::Translator::Schema::Field->new( > name => 'datetime_with_TZ', > table => $table, > data_type => 'timestamp with time zone', > size => 7, > ); > my $field3_datetime_with_TZ_sql = SQL::Translator::Producer::PostgreSQL::create_field($field3_datetime_with_TZ); > is($field3_datetime_with_TZ_sql, 'datetime_with_TZ timestamp(6) with time zone', 'Create time field with time zone and size, works'); > > > my $field3_time_without_TZ = SQL::Translator::Schema::Field->new( > name => 'time_without_TZ', > table => $table, > data_type => 'time without time zone', > size => 2, > ); > my $field3_time_without_TZ_sql = SQL::Translator::Producer::PostgreSQL::create_field($field3_time_without_TZ); > is($field3_time_without_TZ_sql, 'time_without_TZ time(2) without time zone', 'Create time field without time zone but with size, works'); > >
I think someone else applied a similar patch to the Producer earlier, I applied the given test patch. See SVN r1613.