From: jesse Date: Tue, 14 Aug 2007 21:54:44 +0000 (+0000) Subject: * First cut at shutting up index/unique calls from within the codebase. X-Git-Tag: DBIx_DBSchema_0_34~3 X-Git-Url: http://git.freeside.biz/gitweb/?p=DBIx-DBSchema.git;a=commitdiff_plain;h=b604a6e28009f97d206156bf3fa1eeeb6b5063f9 * First cut at shutting up index/unique calls from within the codebase. (Split out the internal usage into _private methods) --- diff --git a/DBSchema.pm b/DBSchema.pm index b821d16..4ff8fa0 100644 --- a/DBSchema.pm +++ b/DBSchema.pm @@ -364,18 +364,18 @@ sub pretty_print { #old style index representation.. ( - $table->{'unique'} # $table->unique + $table->{'unique'} # $table->_unique ? " 'unique' => [ ". join(', ', map { "[ '". join("', '", @{$_}). "' ]" } - @{$table->unique->lol_ref} + @{$table->_unique->lol_ref} ). " ],\n" : '' ). - ( $table->{'index'} # $table->index + ( $table->{'index'} # $table->_index ? " 'index' => [ ". join(', ', map { "[ '". join("', '", @{$_}). "' ]" } - @{$table->index->lol_ref} + @{$table->_index->lol_ref} ). " ],\n" : '' ). @@ -390,7 +390,7 @@ sub pretty_print { ? " 'using' => '". $index->using ."',\n" : '' ). - " 'unique' => ". $index->unique .",\n". + " 'unique' => ". $index->_unique .",\n". " 'columns' => [ '". join("', '", @{$index->columns} ). "' ],\n". diff --git a/DBSchema/Table.pm b/DBSchema/Table.pm index b19e7ef..1e70525 100644 --- a/DBSchema/Table.pm +++ b/DBSchema/Table.pm @@ -377,11 +377,18 @@ Returns or sets the DBIx::DBSchema::ColGroup::Unique object. =cut -sub unique { - my($self,$value)=@_; +sub unique { + my $self = shift; + carp ref($self) . "->unique method is deprecated; see ->indices"; + + #croak ref($self). "->unique method is deprecated; see ->indices"; + $self->_unique(@_); + +} + +sub _unique { - carp ref($self). "->unique method is deprecated; see ->indices"; - #croak ref($self). "->unique method is deprecated; see ->indices"; + my ($self,$value)=@_; if ( defined($value) ) { $self->{unique} = $value; @@ -401,10 +408,17 @@ Returns or sets the DBIx::DBSchema::ColGroup::Index object. =cut sub index { - my($self,$value)=@_; + my $self = shift; carp ref($self). "->index method is deprecated; see ->indices"; #croak ref($self). "->index method is deprecated; see ->indices"; + $self->_index(@_); + +} + + +sub _index { + my($self,$value)=@_; if ( defined($value) ) { $self->{'index'} = $value; @@ -520,7 +534,7 @@ sub sql_create_table { "CREATE TABLE ". $self->name. " (\n ". join(",\n ", @columns). "\n)\n" ); - if ( $self->unique ) { + if ( $self->_unique ) { warn "WARNING: DBIx::DBSchema::Table object for ". $self->name. " table has deprecated (non-named) unique indices\n"; @@ -534,7 +548,7 @@ sub sql_create_table { } - if ( $self->index ) { + if ( $self->_index ) { warn "WARNING: DBIx::DBSchema::Table object for ". $self->name. " table has deprecated (non-named) indices\n";