From d57e2a229dd314166741e8f41aa0f811d568ec3b Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 4 Mar 2002 12:59:13 +0000 Subject: [PATCH] 0.20 --- Changes | 8 ++++++++ DBSchema.pm | 2 +- DBSchema/DBD/Pg.pm | 24 +++++++++++++++++------- DBSchema/Table.pm | 4 ++-- README | 4 ++-- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Changes b/Changes index 3845dec..0edd7d8 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,13 @@ Revision history for Perl extension DBIx::DBSchema. +0.20 Mon Mar 4 04:58:34 2002 + - documentation updates + - fix Column->new when using named params + - fix Pg driver reverse-engineering length of numeric columns: + translate 655362 to 10,2, etc. + - fix Pg driver reverse-engineering of text columns (don't have a + length) + 0.19 Tue Oct 23 08:49:12 2001 - documentation for %typemap - preliminary Sybase driver from Charles Shapiro diff --git a/DBSchema.pm b/DBSchema.pm index 420d44f..c914a94 100644 --- a/DBSchema.pm +++ b/DBSchema.pm @@ -14,7 +14,7 @@ use DBIx::DBSchema::ColGroup::Index; #@ISA = qw(Exporter); @ISA = (); -$VERSION = "0.19"; +$VERSION = "0.20"; =head1 NAME diff --git a/DBSchema/DBD/Pg.pm b/DBSchema/DBD/Pg.pm index 76bcf2d..047a6c5 100644 --- a/DBSchema/DBD/Pg.pm +++ b/DBSchema/DBD/Pg.pm @@ -4,7 +4,7 @@ use strict; use vars qw($VERSION @ISA %typemap); use DBIx::DBSchema::DBD; -$VERSION = '0.03'; +$VERSION = '0.04'; @ISA = qw(DBIx::DBSchema::DBD); %typemap = ( @@ -41,17 +41,27 @@ sub columns { END $sth->execute or die $sth->errstr; map { + + my $len = ''; + if ( $_->{attlen} == -1 && $_->{typname} ne 'text' ) { + $len = $_->{atttypmod} - 4; + if ( $_->{typname} eq 'numeric' ) { + $len = ($len >> 16). ','. ($len & 0xffff); + } + } + + my $type = $_->{'typname'}; + $type = 'char' if $type eq 'bpchar'; + [ $_->{'attname'}, - $_->{'typname'}, + $type, ! $_->{'attnotnull'}, - ( $_->{'attlen'} == -1 - ? $_->{'atttypmod'} - 4 - : '' - ), + $len, '', #default '' #local - ] + ]; + } @{ $sth->fetchall_arrayref({}) }; } diff --git a/DBSchema/Table.pm b/DBSchema/Table.pm index 7714a15..0479de7 100644 --- a/DBSchema/Table.pm +++ b/DBSchema/Table.pm @@ -31,7 +31,7 @@ DBIx::DBSchema::Table - Table objects #new style (preferred), pass a hashref of parameters $table = new DBIx::DBSchema::Table ( { - table => "table_name", + name => "table_name", primary_key => "primary_key", unique => $dbix_dbschema_colgroup_unique_object, 'index' => $dbix_dbschema_colgroup_index_object, @@ -105,7 +105,7 @@ sub new { if ( ref($_[0]) ) { $self = shift; - $self->{column_order} = [ map { $_->_name } @{$self->{columns}} ]; + $self->{column_order} = [ map { $_->name } @{$self->{columns}} ]; $self->{columns} = { map { $_->name, $_ } @{$self->{columns}} }; } else { diff --git a/README b/README index 67d434a..217477e 100644 --- a/README +++ b/README @@ -15,7 +15,7 @@ CREATE statements for different databases from a single source. Currently supported databases are MySQL and PostgreSQL. Sybase support is partially implemented. DBIx::DBSchema will attempt to use generic SQL syntax for other databases. Assistance adding support for other databases is -welcomed. See the DBIx::DBSchema::DBD> manpage, "Driver Writer's Guide and +welcomed. See the DBIx::DBSchema::DBD manpage, "Driver Writer's Guide and Base Class". To install: @@ -40,4 +40,4 @@ A mailing list is available. Send a blank message to Homepage: -$Id: README,v 1.6 2001-09-05 16:20:03 ivan Exp $ +$Id: README,v 1.7 2002-03-04 12:59:13 ivan Exp $ -- 2.11.0