From: Peter Rabbitson Date: Thu, 10 Jan 2013 13:39:08 +0000 (+0100) Subject: Deprecate emulate_limit() - can not be sanely supported by DQ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=67341081b1a57cc8549e51a8fb1b8cd4661543c5;p=dbsrgits%2FDBIx-Class-Historic.git Deprecate emulate_limit() - can not be sanely supported by DQ --- diff --git a/Changes b/Changes index 2751605..b187054 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for DBIx::Class + * New Features / Changes + - The emulate_limit() arbitrary limit dialect emulation mechanism is + now deprecated, and will be removed when DBIx::Class migrates to + Data::Query * Fixes - When performing resultset update/delete only strip condition qualifiers - leave the source name alone (RT#80015, RT#78844) diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index 34b9c80..b45fd68 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -133,16 +133,25 @@ sub select { ($sql, @bind) = $self->next::method ($table, $fields, $where); - my $limiter = - $self->can ('emulate_limit') # also backcompat hook from SQLA::Limit - || - do { - my $dialect = $self->limit_dialect - or $self->throw_exception( "Unable to generate SQL-limit - no limit dialect specified on $self, and no emulate_limit method found" ); - $self->can ("_$dialect") - or $self->throw_exception(__PACKAGE__ . " does not implement the requested dialect '$dialect'"); - } - ; + my $limiter; + + if( $limiter = $self->can ('emulate_limit') ) { + carp_unique( + 'Support for the legacy emulate_limit() mechanism inherited from ' + . 'SQL::Abstract::Limit has been deprecated, and will be removed when ' + . 'DBIC transitions to Data::Query. If your code uses this type of ' + . 'limit specification please file an RT and provide the source of ' + . 'your emulate_limit() implementation, so an acceptable upgrade-path ' + . 'can be devised' + ); + } + else { + my $dialect = $self->limit_dialect + or $self->throw_exception( "Unable to generate SQL-limit - no limit dialect specified on $self" ); + + $limiter = $self->can ("_$dialect") + or $self->throw_exception(__PACKAGE__ . " does not implement the requested dialect '$dialect'"); + } $sql = $self->$limiter ( $sql, diff --git a/t/sqlmaker/limit_dialects/custom.t b/t/sqlmaker/limit_dialects/custom.t index 650cd99..1bf3e07 100644 --- a/t/sqlmaker/limit_dialects/custom.t +++ b/t/sqlmaker/limit_dialects/custom.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; +use Test::Warn; use lib qw(t/lib); use DBICTest; @@ -27,7 +28,8 @@ my $s = DBICTest::Schema->connect (DBICTest->_database); $s->storage->sql_maker_class ('DBICTest::SQLMaker::CustomDialect'); my $rs = $s->resultset ('CD'); -is_same_sql_bind ( + +warnings_exist { is_same_sql_bind ( $rs->search ({}, { rows => 1, offset => 3,columns => [ { id => 'foo.id' }, { 'bar.id' => 'bar.id' }, @@ -45,6 +47,9 @@ is_same_sql_bind ( )', [], 'Rownum subsel aliasing works correctly' -); + )} + qr/\Qthe legacy emulate_limit() mechanism inherited from SQL::Abstract::Limit has been deprecated/, + 'deprecation warning' +; done_testing;