Skip to content

Commit

Permalink
Cherry picks from current/for_cpan_index (flux due to not-yet-clear-p…
Browse files Browse the repository at this point in the history
…olicy)

This is an amalgamation of:
- f6fff27
- 293dccf (corrected version of b63585b)
- 77cc50d
  • Loading branch information
ribasushi committed Oct 21, 2014
1 parent 2131aa2 commit 1d29e7e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 16 additions & 7 deletions lib/DBIx/Class/SQLMaker/OracleJoins.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
22 changes: 19 additions & 3 deletions lib/DBIx/Class/Storage/DBIHacks.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1204,14 +1204,15 @@ 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 } };
}
elsif (ref $rhs eq 'HASH' and keys %$rhs == 1 and exists $rhs->{-value} and is_plain_value $rhs->{-value}) {
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 {
Expand All @@ -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 } }
;
Expand Down Expand Up @@ -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->{'='};
}
}
Expand Down
7 changes: 3 additions & 4 deletions maint/Makefile.PL.inc/29_handle_version.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
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` };
Expand Down
28 changes: 25 additions & 3 deletions t/sqlmaker/oraclejoin.t
Original file line number Diff line number Diff line change
Expand Up @@ -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' ],
Expand All @@ -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' ],
Expand All @@ -52,12 +54,30 @@ is_same_sql_bind(
'WhereJoins search with where clause'
);

($sql, @bind) = $sa->select(
[
{ 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' ],
Expand All @@ -70,5 +90,7 @@ is_same_sql_bind(
'WhereJoins search with or in where clause'
);

}

done_testing;

2 changes: 1 addition & 1 deletion xt/optional_deps.t
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1d29e7e

Please sign in to comment.