X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet.pm;h=2f768305085180f9b1920d148dfb722eac86e794;hb=946f626022c63fd269d9d985c2abeabb52871027;hp=d4c271a6720d20b1468bef5d65ccc7f26c662ba2;hpb=977f88cb4a2a252c91a6b4233bc4de59b702b9c1;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index d4c271a..2f76830 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -1739,14 +1739,19 @@ sub _rs_update_delete { # simplify the joinmap and maybe decide if a grouping (and thus subquery) is necessary my $relation_classifications; if (ref($attrs->{from}) eq 'ARRAY') { - $attrs->{from} = $storage->_prune_unused_joins ($attrs->{from}, $attrs->{select}, $cond, $attrs); - - $relation_classifications = $storage->_resolve_aliastypes_from_select_args ( - [ @{$attrs->{from}}[1 .. $#{$attrs->{from}}] ], - $attrs->{select}, - $cond, - $attrs - ) unless $needs_group_by_subq; # we already know we need a group, no point of resolving them + if (@{$attrs->{from}} == 1) { + # not a fucking JOIN at all, quit with the dickery + $relation_classifications = {}; + } else { + $attrs->{from} = $storage->_prune_unused_joins ($attrs->{from}, $attrs->{select}, $cond, $attrs); + + $relation_classifications = $storage->_resolve_aliastypes_from_select_args ( + [ @{$attrs->{from}}[1 .. $#{$attrs->{from}}] ], + $attrs->{select}, + $cond, + $attrs + ) unless $needs_group_by_subq; # we already know we need a group, no point of resolving them + } } else { $needs_group_by_subq ||= 1; # if {from} is unparseable assume the worst @@ -1764,21 +1769,13 @@ sub _rs_update_delete { ) { # Most databases do not allow aliasing of tables in UPDATE/DELETE. Thus # a condition containing 'me' or other table prefixes will not work - # at all. What this code tries to do (badly) is to generate a condition - # with the qualifiers removed, by exploiting the quote mechanism of sqla - # - # this is atrocious and should be replaced by normal sqla introspection - # one sunny day - my ($sql, @bind) = do { - my $sqla = $rsrc->storage->sql_maker; - local $sqla->{_dequalify_idents} = 1; - $sqla->_recurse_where($self->{cond}); - } if $self->{cond}; - + # at all. Tell SQLMaker to dequalify idents via a gross hack. + my $sqla = $rsrc->storage->sql_maker; + local $sqla->{_dequalify_idents} = 1; return $rsrc->storage->$op( $rsrc, $op eq 'update' ? $values : (), - $self->{cond} ? \[$sql, @bind] : (), + $self->{cond}, ); } @@ -3490,6 +3487,7 @@ sub _resolved_attrs { # default order for collapsing unless the user asked for something $attrs->{order_by} = [ map { "$alias.$_" } $source->primary_columns ]; $attrs->{_ordered_for_collapse} = 1; + $attrs->{_order_is_artificial} = 1; } # if both page and offset are specified, produce a combined offset