From: Peter Rabbitson Date: Wed, 26 Dec 2012 19:50:57 +0000 (+0100) Subject: Remove support for source_bind_attributes() as promised in 0e773352a X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9720202815dbafee0d9e944e3f8258d4aca446d4;p=dbsrgits%2FDBIx-Class-Historic.git Remove support for source_bind_attributes() as promised in 0e773352a Original deprecation was put in place almost 2 years ago --- diff --git a/Changes b/Changes index b187054..c42606c 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,8 @@ Revision history for DBIx::Class - The emulate_limit() arbitrary limit dialect emulation mechanism is now deprecated, and will be removed when DBIx::Class migrates to Data::Query + - Support for the source_bind_attributes() storage method has been + removed after a lengthy deprecation cycle * Fixes - When performing resultset update/delete only strip condition qualifiers - leave the source name alone (RT#80015, RT#78844) @@ -15,6 +17,8 @@ Revision history for DBIx::Class (RT#78436) * Misc - Improve the populate docs in ::Schema and ::ResultSet + - ::Storage::DBI::source_bind_attributes() removed as announced + on Jan 2011 in 0e773352a 0.08204 2012-11-08 * New Features / Changes diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 5332582..4ef923c 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1247,6 +1247,15 @@ sub _determine_driver { Class::C3->reinitialize() if DBIx::Class::_ENV_::OLD_MRO; + if ($self->can('source_bind_attributes')) { + $self->throw_exception( + "Your storage subclass @{[ ref $self ]} provides (or inherits) the method " + . 'source_bind_attributes() for which support has been removed as of Jan 2013. ' + . 'If you are not sure how to proceed please contact the development team via ' + . 'http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class.pm#GETTING_HELP/SUPPORT' + ); + } + $self->_init; # run driver-specific initializations $self->_run_connection_actions @@ -1651,30 +1660,9 @@ sub _query_end { if $self->debug; } -my $sba_compat; sub _dbi_attrs_for_bind { my ($self, $ident, $bind) = @_; - if (! defined $sba_compat) { - $self->_determine_driver; - $sba_compat = $self->can('source_bind_attributes') == \&source_bind_attributes - ? 0 - : 1 - ; - } - - my $sba_attrs; - if ($sba_compat) { - my $class = ref $self; - carp_unique ( - "The source_bind_attributes() override in $class relies on a deprecated codepath. " - .'You are strongly advised to switch your code to override bind_attribute_by_datatype() ' - .'instead. This legacy compat shim will also disappear some time before DBIC 0.09' - ); - - my $sba_attrs = $self->source_bind_attributes - } - my @attrs; for (map { $_->[0] } @$bind) { @@ -1691,9 +1679,6 @@ sub _dbi_attrs_for_bind { } $cache->{$_->{sqlt_datatype}}; } - elsif ($sba_attrs and $_->{dbic_colname}) { - $sba_attrs->{$_->{dbic_colname}} || undef; - } else { undef; # always push something at this position } @@ -2353,15 +2338,6 @@ sub _count_select { return { count => '*' }; } -sub source_bind_attributes { - shift->throw_exception( - 'source_bind_attributes() was never meant to be a callable public method - ' - .'please contact the DBIC dev-team and describe your use case so that a reasonable ' - .'solution can be provided' - ."\nhttp://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class.pm#GETTING_HELP/SUPPORT" - ); -} - =head2 select =over 4 diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 6ae6344..bf5bb47 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -332,8 +332,6 @@ my $method_dispatch = { _arm_global_destructor _verify_pid - source_bind_attributes - get_use_dbms_capability set_use_dbms_capability get_dbms_capability diff --git a/t/storage/deprecated_exception_source_bind_attrs.t b/t/storage/deprecated_exception_source_bind_attrs.t new file mode 100644 index 0000000..f6dca5a --- /dev/null +++ b/t/storage/deprecated_exception_source_bind_attrs.t @@ -0,0 +1,30 @@ +use strict; +use warnings; + +use Test::More; +use Test::Warn; +use Test::Exception; +use lib qw(t/lib); +use DBICTest; + +{ + package DBICTest::Legacy::Storage; + use base 'DBIx::Class::Storage::DBI::SQLite'; + + use Data::Dumper::Concise; + + sub source_bind_attributes { return {} } +} + + +my $schema = DBICTest::Schema->clone; +$schema->storage_type('DBICTest::Legacy::Storage'); +$schema->connection('dbi:SQLite::memory:'); + +throws_ok + { $schema->storage->ensure_connected } + qr/\Qstorage subclass DBICTest::Legacy::Storage provides (or inherits) the method source_bind_attributes()/, + 'deprecated use of source_bind_attributes throws', +; + +done_testing; diff --git a/t/storage/source_bind_compat.t b/t/storage/source_bind_compat.t deleted file mode 100644 index 268f6a8..0000000 --- a/t/storage/source_bind_compat.t +++ /dev/null @@ -1,49 +0,0 @@ -use strict; -use warnings; - -use Test::More; -use Test::Warn; -use Test::Exception; -use lib qw(t/lib); -use DBICTest; - -{ - package DBICTest::Legacy::Storage; - use base 'DBIx::Class::Storage::DBI::SQLite'; - - use Data::Dumper::Concise; - - sub source_bind_attributes { return {} } -} - - -my $schema = DBICTest::Schema->clone; -$schema->storage_type('DBICTest::Legacy::Storage'); -$schema->connection('dbi:SQLite::memory:'); - -$schema->storage->dbh_do( sub { $_[1]->do(<<'EOS') } ); -CREATE TABLE artist ( - artistid INTEGER PRIMARY KEY NOT NULL, - name varchar(100), - rank integer NOT NULL DEFAULT 13, - charfield char(10) -) -EOS - -my $legacy = sub { $schema->resultset('Artist')->search({ name => 'foo'})->next }; -if (DBIx::Class->VERSION >= 0.09) { - &throws_ok( - $legacy, - qr/XXXXXXXXX not sure what error to put here yet XXXXXXXXXXXXXXX/, - 'deprecated use of source_bind_attributes throws', - ); -} -else { - &warnings_exist ( - $legacy, - qr/\QThe source_bind_attributes() override in DBICTest::Legacy::Storage relies on a deprecated codepath/, - 'Warning issued during invocation of legacy storage codepath', - ); -} - -done_testing;