Skip Menu |
 

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

Report information
The Basics
Id: 82515
Status: new
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: sebastian [...] podjasek.pl
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.11016
Fixed in: (no value)



Subject: PostgreSQL Parser - new data types
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 133
Download (untitled) / with headers
text/plain 133b
Parser for PostgreSQL fails on some valid, but unimplemented data types, for ex. uuid, time with time zone... See attached quick fix
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1357477877-7056-11"
Message-ID: <rt-3.8.HEAD-7056-1357477877-1284.82515-0-0 [...] rt.cpan.org>
From: sebastian [...] podjasek.pl
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 5
Patch
MIME-Version: 1.0
Subject: sqlt-fix.patch
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/x-patch; name="sqlt-fix.patch"
Content-Disposition: inline; filename="sqlt-fix.patch"
Content-Transfer-Encoding: binary
Content-Length: 3051
Download sqlt-fix.patch
text/x-diff 2.9k
diff --git a/lib/SQL/Translator/Parser/PostgreSQL.pm b/lib/SQL/Translator/Parser/PostgreSQL.pm index ac59c4b..f050ff3 100644 --- a/lib/SQL/Translator/Parser/PostgreSQL.pm +++ b/lib/SQL/Translator/Parser/PostgreSQL.pm @@ -631,6 +631,11 @@ pg_data_type : $return = { type => 'timestamp' . ($2||'') }; } | + /(timetz|time)(?:\(\d\))?( with(?:out)? time zone)?/i + { + $return = { type => 'time' . ($2||'') }; + } + | /text/i { $return = { @@ -639,7 +644,7 @@ pg_data_type : }; } | - /(bit|box|cidr|circle|date|inet|line|lseg|macaddr|money|numeric|decimal|path|point|polygon|timetz|time|varchar)/i + /(bit|box|cidr|circle|date|inet|line|lseg|macaddr|money|numeric|decimal|path|point|polygon|uuid|varchar)/i { $return = { type => $item[1] }; } diff --git a/t/14postgres-parser.t b/t/14postgres-parser.t index 3e7e4ea..ffc202f 100644 --- a/t/14postgres-parser.t +++ b/t/14postgres-parser.t @@ -29,7 +29,10 @@ my $sql = q{ f_fk1 integer not null references t_test2 (f_id), f_dropped text, f_timestamp timestamp(0) with time zone, - f_timestamp2 timestamp without time zone + f_timestamp2 timestamp without time zone, + f_uuid uuid, + f_time time(0) with time_zone, + f_time2 time without time zone ); create table t_test2 ( @@ -224,6 +227,33 @@ is( $f12->default_value, undef, 'Default value is "undef"' ); is( $f12->is_primary_key, 0, 'Field is not PK' ); is( $f12->is_foreign_key, 0, 'Field is not FK' ); +my $f13 = shift @t1_fields; +is( $f13->name, 'f_uuid', '13th field is "f_uuid"' ); +is( $f13->data_type, 'uuid', 'Field is a UUID' ); +is( $f13->is_nullable, 1, 'Field can be null' ); +is( $f13->size, 0, 'Size is "0"' ); +is( $f13->default_value, undef, 'Default value is "undef"' ); +is( $f13->is_primary_key, 0, 'Field is not PK' ); +is( $f13->is_foreign_key, 0, 'Field is not FK' ); + +my $f14 = shift @t1_fields; +is( $f14->name, 'f_time', '14th field is "f_time"' ); +is( $f14->data_type, 'time with time zone', 'Field is a time with time zone' ); +is( $f14->is_nullable, 1, 'Field can be null' ); +is( $f14->size, 0, 'Size is "0"' ); +is( $f14->default_value, undef, 'Default value is "undef"' ); +is( $f14->is_primary_key, 0, 'Field is not PK' ); +is( $f14->is_foreign_key, 0, 'Field is not FK' ); + +my $f15 = shift @t1_fields; +is( $f15->name, 'f_time2', '15th field is "f_time2"' ); +is( $f15->data_type, 'time without time zone', 'Field is a time without time zone' ); +is( $f15->is_nullable, 1, 'Field can be null' ); +is( $f15->size, 0, 'Size is "0"' ); +is( $f15->default_value, undef, 'Default value is "undef"' ); +is( $f15->is_primary_key, 0, 'Field is not PK' ); +is( $f15->is_foreign_key, 0, 'Field is not FK' ); + # my $fk_ref2 = $f11->foreign_key_reference; # isa_ok( $fk_ref2, 'SQL::Translator::Schema::Constraint', 'FK' ); # is( $fk_ref2->reference_table, 't_test2', 'FK is to "t_test2" table' );


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.