From: Rafael Kitover Date: Sun, 9 May 2010 08:19:40 +0000 (-0400) Subject: rewrite Pg "time without time zone" as "time" X-Git-Tag: 0.07000~29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e030521a92b75a891d72ebfb58404f33095495e;p=dbsrgits%2FDBIx-Class-Schema-Loader.git rewrite Pg "time without time zone" as "time" --- diff --git a/TODO b/TODO index 96451a3..6db4250 100644 --- a/TODO +++ b/TODO @@ -37,6 +37,7 @@ - correct handling of CamelCase names with numbers (eg. foo2Bar -> Foo2Bar, foo2_bar) - check rel accessors for method conflicts + - add an option to add extra code to Result classes - Relationships - Re-scan relations/tables after initial relation setup to find @@ -68,7 +69,6 @@ - preserve_case mode - domains - Oracle - - data_type tests - table/column comments - introspect on_update/on_delete/is_deferrable - introspect view SQL diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 1910923..5547653 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -150,6 +150,9 @@ sub _columns_info_for { if (lc($data_type) eq 'timestamp without time zone') { $info->{data_type} = 'timestamp'; } + elsif (lc($data_type) eq 'time without time zone') { + $info->{data_type} = 'time'; + } my ($precision) = $self->schema->storage->dbh ->selectrow_array(<{data_type} = 'varchar'; - $info->{data_type} = 'text' if not $info->{size}; + if (not $info->{size}) { + $info->{data_type} = 'text'; + $info->{original}{data_type} = 'varchar'; + } } elsif (lc($data_type) eq 'character') { $info->{data_type} = 'char'; diff --git a/t/12pg_common.t b/t/12pg_common.t index 4e94015..8b18c58 100644 --- a/t/12pg_common.t +++ b/t/12pg_common.t @@ -79,16 +79,17 @@ my $tester = dbixcsl_common_tests->new( 'char' => { data_type => 'char', size => 1 }, text => { data_type => 'text' }, # varchar with no size has unlimited size, we rewrite to 'text' - varchar => { data_type => 'text' }, + varchar => { data_type => 'text', + original => { data_type => 'varchar' } }, # Datetime Types date => { data_type => 'date' }, interval => { data_type => 'interval' }, 'interval(2)' => { data_type => 'interval', size => 2 }, - time => { data_type => 'time without time zone' }, - 'time(2)' => { data_type => 'time without time zone', size => 2 }, - 'time without time zone' => { data_type => 'time without time zone' }, - 'time(2) without time zone' => { data_type => 'time without time zone', size => 2 }, + time => { data_type => 'time' }, + 'time(2)' => { data_type => 'time', size => 2 }, + 'time without time zone' => { data_type => 'time' }, + 'time(2) without time zone' => { data_type => 'time', size => 2 }, 'time with time zone' => { data_type => 'time with time zone' }, 'time(2) with time zone' => { data_type => 'time with time zone', size => 2 }, timestamp => { data_type => 'timestamp' },