From: Peter Rabbitson Date: Mon, 15 Sep 2014 06:22:24 +0000 (+0200) Subject: Put in place deprecation forgotten for several years X-Git-Tag: v0.082800~40 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=1efc866d8235ddd640d956352d59036a1cd3bbd7 Put in place deprecation forgotten for several years More info and rationale in the commit msg of c200d949 --- diff --git a/Changes b/Changes index 5639669..e18f607 100644 --- a/Changes +++ b/Changes @@ -16,6 +16,8 @@ Revision history for DBIx::Class objects that went out of sync with the storage (RT#96499) - CDBICompat::columns() now supports adding columns through supplied Class::DBI::Column instances (GH#52) + - Deprecate { col1 => col2 } expressions in manual from structures + (at some point of time manual from will be deprecated itself) * Fixes - Fix Resultset delete/update affecting *THE ENTIRE TABLE* in cases diff --git a/lib/DBIx/Class/SQLMaker.pm b/lib/DBIx/Class/SQLMaker.pm index 6213c8b..791e4fc 100644 --- a/lib/DBIx/Class/SQLMaker.pm +++ b/lib/DBIx/Class/SQLMaker.pm @@ -452,8 +452,6 @@ sub _join_condition { # Backcompat for the old days when a plain hashref # { 't1.col1' => 't2.col2' } meant ON t1.col1 = t2.col2 - # Once things settle we should start warning here so that - # folks unroll their hacks if ( ref $cond eq 'HASH' and @@ -463,6 +461,12 @@ sub _join_condition { and ! ref ( (values %$cond)[0] ) ) { + carp_unique( + "ResultSet {from} structures with conditions not conforming to the " + . "SQL::Abstract syntax are deprecated: you either need to stop abusing " + . "{from} altogether, or express the condition properly using the " + . "{ -ident => ... } operator" + ); $cond = { keys %$cond => { -ident => values %$cond } } } elsif ( ref $cond eq 'ARRAY' ) { diff --git a/t/search/subquery.t b/t/search/subquery.t index 87195fd..8c3fcf7 100644 --- a/t/search/subquery.t +++ b/t/search/subquery.t @@ -6,6 +6,7 @@ use Test::More; use lib qw(t/lib); use DBICTest ':DiffSQL'; use DBIx::Class::SQLMaker::LimitDialects; +use DBIx::Class::_Util 'sigwarn_silencer'; my $ROWS = DBIx::Class::SQLMaker::LimitDialects->__rows_bindtype; @@ -164,6 +165,8 @@ my @tests = ( for my $i (0 .. $#tests) { my $t = $tests[$i]; for my $p (1, 2) { # repeat everything twice, make sure we do not clobber search arguments + local $SIG{__WARN__} = sigwarn_silencer( qr/\Q{from} structures with conditions not conforming to the SQL::Abstract syntax are deprecated/ ); + is_same_sql_bind ( $t->{rs}->search ($t->{search}, $t->{attrs})->as_query, $t->{sqlbind}, diff --git a/t/sqlmaker/core_quoted.t b/t/sqlmaker/core_quoted.t index e90befe..8e45566 100644 --- a/t/sqlmaker/core_quoted.t +++ b/t/sqlmaker/core_quoted.t @@ -24,7 +24,7 @@ my ($sql, @bind) = $sql_maker->select( '-join_type' => '' }, { - 'artist.artistid' => 'me.artist' + 'artist.artistid' => { -ident => 'me.artist' }, } ], [ @@ -33,7 +33,7 @@ my ($sql, @bind) = $sql_maker->select( '-join_type' => 'left' }, { - 'tracks.cd' => 'me.cdid' + 'tracks.cd' => { -ident => 'me.cdid' }, } ], ], @@ -307,7 +307,7 @@ $sql_maker->quote_char([qw/[ ]/]); '-join_type' => '' }, { - 'artist.artistid' => 'me.artist' + 'artist.artistid' => { -ident => 'me.artist' } } ] ], diff --git a/t/sqlmaker/legacy_joins.t b/t/sqlmaker/legacy_joins.t index 5d17e99..1c93c35 100644 --- a/t/sqlmaker/legacy_joins.t +++ b/t/sqlmaker/legacy_joins.t @@ -4,10 +4,13 @@ use warnings; use Test::More; use lib qw(t/lib); use DBICTest ':DiffSQL'; +use DBIx::Class::_Util 'sigwarn_silencer'; use DBIx::Class::SQLMaker; my $sa = DBIx::Class::SQLMaker->new; +$SIG{__WARN__} = sigwarn_silencer( qr/\Q{from} structures with conditions not conforming to the SQL::Abstract syntax are deprecated/ ); + my @j = ( { child => 'person' }, [ { father => 'person' }, { 'father.person_id' => 'child.father_id' }, ], diff --git a/t/sqlmaker/msaccess.t b/t/sqlmaker/msaccess.t index 0333cb2..179b3f3 100644 --- a/t/sqlmaker/msaccess.t +++ b/t/sqlmaker/msaccess.t @@ -86,7 +86,7 @@ my ($sql, @bind) = $sa->select( { me => "cd" }, [ { "-join_type" => "LEFT", artist => "artist" }, - { "artist.artistid" => "me.artist" }, + { "artist.artistid" => { -ident => "me.artist" } }, ], ], [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], @@ -104,11 +104,11 @@ is_same_sql_bind( { me => "cd" }, [ { "-join_type" => "LEFT", track => "track" }, - { "track.cd" => "me.cdid" }, + { "track.cd" => { -ident => "me.cdid" } }, ], [ { artist => "artist" }, - { "artist.artistid" => "me.artist" }, + { "artist.artistid" => { -ident => "me.artist" } }, ], ], [ 'track.title', 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],