From: Peter Rabbitson Date: Fri, 26 Sep 2014 02:20:51 +0000 (+0200) Subject: Cherry picks from current/for_cpan_index (flux due to not-yet-clear-policy) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d29e7e26524c98be9ce63a91ec91b1e0d75c03d;p=dbsrgits%2FDBIx-Class.git Cherry picks from current/for_cpan_index (flux due to not-yet-clear-policy) This is an amalgamation of: - f6fff270 - 293dccfc (corrected version of b63585bd) - 77cc50d1 --- diff --git a/Changes b/Changes index 7d23dd9..547e8cb 100644 --- a/Changes +++ b/Changes @@ -9,7 +9,7 @@ Revision history for DBIx::Class - Avoid loading DBICTest::Schema unnecessarily in tests that are being skipped -0.082800 2014-09-25 14:45 (UTC) +0.082801 2014-10-05 23:55 (UTC) * Known Issues - Passing large amounts of objects with stringification overload directly to DBIx::Class may result in strange action at a distance diff --git a/lib/DBIx/Class/SQLMaker/OracleJoins.pm b/lib/DBIx/Class/SQLMaker/OracleJoins.pm index fe9bd07..0f50467 100644 --- a/lib/DBIx/Class/SQLMaker/OracleJoins.pm +++ b/lib/DBIx/Class/SQLMaker/OracleJoins.pm @@ -93,13 +93,22 @@ sub _recurse_oracle_joins { @{$on->{-and}} == 1 ); - # sadly SQLA treats where($scalar) as literal, so we need to jump some hoops - push @where, map { \sprintf ('%s%s = %s%s', - ref $_ ? $self->_recurse_where($_) : $self->_quote($_), - $left_join, - ref $on->{$_} ? $self->_recurse_where($on->{$_}) : $self->_quote($on->{$_}), - $right_join, - )} keys %$on; + + push @where, map { \do { + my ($sql) = $self->_recurse_where({ + # FIXME - more borkage, more or less a copy of the kludge in ::SQLMaker::_join_condition() + $_ => ( length ref $on->{$_} + ? $on->{$_} + : { -ident => $on->{$_} } + ) + }); + + $sql =~ s/\s*\=/$left_join =/ + if $left_join; + + "$sql$right_join"; + } + } sort keys %$on; } return { -and => \@where }; diff --git a/lib/DBIx/Class/Storage/DBIHacks.pm b/lib/DBIx/Class/Storage/DBIHacks.pm index f8f908d..29b7f13 100644 --- a/lib/DBIx/Class/Storage/DBIHacks.pm +++ b/lib/DBIx/Class/Storage/DBIHacks.pm @@ -1204,6 +1204,7 @@ sub _collapse_cond_unroll_pairs { if (ref $rhs eq 'HASH' and ! keys %$rhs) { # FIXME - SQLA seems to be doing... nothing...? } + # normalize top level -ident, for saner extract_fixed_condition_columns code elsif (ref $rhs eq 'HASH' and keys %$rhs == 1 and exists $rhs->{-ident}) { push @conds, { $lhs => { '=', $rhs } }; } @@ -1211,7 +1212,7 @@ sub _collapse_cond_unroll_pairs { push @conds, { $lhs => $rhs->{-value} }; } elsif (ref $rhs eq 'HASH' and keys %$rhs == 1 and exists $rhs->{'='}) { - if( is_literal_value $rhs->{'='}) { + if ( length ref $rhs->{'='} and is_literal_value $rhs->{'='} ) { push @conds, { $lhs => $rhs }; } else { @@ -1229,7 +1230,14 @@ sub _collapse_cond_unroll_pairs { my ($l, $r) = %$p; - push @conds, ( ! length ref $r or is_plain_value($r) ) + push @conds, ( + ! length ref $r + or + # the unroller recursion may return a '=' prepended value already + ref $r eq 'HASH' and keys %$rhs == 1 and exists $rhs->{'='} + or + is_plain_value($r) + ) ? { $l => $r } : { $l => { '=' => $r } } ; @@ -1327,7 +1335,15 @@ sub _extract_fixed_condition_columns { } } # do not need to check for plain values - _collapse_cond did it for us - elsif(length ref $v->{'='} and is_literal_value($v->{'='}) ) { + elsif( + length ref $v->{'='} + and + ( + ( ref $v->{'='} eq 'HASH' and keys %{$v->{'='}} == 1 and exists $v->{'='}{-ident} ) + or + is_literal_value($v->{'='}) + ) + ) { $vals->{ 'SER_' . serialize $v->{'='} } = $v->{'='}; } } diff --git a/maint/Makefile.PL.inc/29_handle_version.pl b/maint/Makefile.PL.inc/29_handle_version.pl index 864fc67..b97c2f0 100644 --- a/maint/Makefile.PL.inc/29_handle_version.pl +++ b/maint/Makefile.PL.inc/29_handle_version.pl @@ -16,10 +16,9 @@ if ($v_maj > 8) { die "Illegal version $version_string - we are still in the 0.08 cycle\n" } -Meta->makemaker_args->{DISTVNAME} = Meta->name . "-$version_string-TRIAL" if ( - # all odd releases *after* 0.089x generate a -TRIAL, no exceptions - ( $v_point > 89 ) -); +#Meta->makemaker_args->{DISTVNAME} = Meta->name . "-$version_string-TRIAL" if ( +# ( $v_point > 89 ) +#); my $tags = { map { chomp $_; $_ => 1} `git tag` }; diff --git a/t/sqlmaker/oraclejoin.t b/t/sqlmaker/oraclejoin.t index c1725e0..e8e7444 100644 --- a/t/sqlmaker/oraclejoin.t +++ b/t/sqlmaker/oraclejoin.t @@ -15,13 +15,15 @@ use DBIx::Class::SQLMaker::OracleJoins; my $sa = DBIx::Class::SQLMaker::OracleJoins->new; +for my $rhs ( "me.artist", { -ident => "me.artist" } ) { + # my ($self, $table, $fields, $where, $order, @rest) = @_; my ($sql, @bind) = $sa->select( [ { me => "cd" }, [ { "-join_type" => "LEFT", artist => "artist" }, - { "artist.artistid" => "me.artist" }, + { "artist.artistid" => $rhs }, ], ], [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], @@ -39,7 +41,7 @@ is_same_sql_bind( { me => "cd" }, [ { "-join_type" => "", artist => "artist" }, - { "artist.artistid" => "me.artist" }, + { "artist.artistid" => $rhs }, ], ], [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], @@ -56,8 +58,26 @@ is_same_sql_bind( [ { me => "cd" }, [ + { "-join_type" => "right", artist => "artist" }, + { "artist.artistid" => $rhs }, + ], + ], + [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], + { 'artist.artistid' => 3 }, + undef +); +is_same_sql_bind( + $sql, \@bind, + 'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid = me.artist(+) ) AND ( artist.artistid = ? ) ) )', [3], + 'WhereJoins search with where clause' +); + +($sql, @bind) = $sa->select( + [ + { me => "cd" }, + [ { "-join_type" => "LEFT", artist => "artist" }, - { "artist.artistid" => "me.artist" }, + { "artist.artistid" => $rhs }, ], ], [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ], @@ -70,5 +90,7 @@ is_same_sql_bind( 'WhereJoins search with or in where clause' ); +} + done_testing; diff --git a/xt/optional_deps.t b/xt/optional_deps.t index 781273c..efb7edf 100644 --- a/xt/optional_deps.t +++ b/xt/optional_deps.t @@ -9,7 +9,7 @@ use Scalar::Util; # load before we break require() use Carp (); # Carp is not used in the test, but we want to have it loaded for proper %INC comparison # a dummy test which lazy-loads more modules (so we can compare INC below) -ok (1); +is_deeply([], []); # record contents of %INC - makes sure there are no extra deps slipping into # Opt::Dep.