1 package DBIx::Class::Storage::DBI::MultiColumnIn;
6 use base 'DBIx::Class::Storage::DBI';
11 DBIx::Class::Storage::DBI::MultiColumnIn - Storage component for RDBMS supporting multicolumn in clauses
15 While ANSI SQL does not define a multicolumn in operator, many databases can
16 in fact understand WHERE (cola, colb) IN ( SELECT subcol_a, subcol_b ... )
17 The storage class for any such RDBMS should inherit from this class, in order
18 to dramatically speed up update/delete operations on joined multipk resultsets.
20 At this point the only overriden method is C<_multipk_update_delete()>
24 sub _multipk_update_delete {
26 my ($rs, $op, $values) = @_;
28 my $rsrc = $rs->result_source;
29 my @pcols = $rsrc->primary_columns;
30 my $attrs = $rs->_resolved_attrs;
32 # naive check - this is an internal method after all, we should know what we are doing
33 $self->throw_exception ('Number of columns selected by supplied resultset does not match number of primary keys')
34 if ( ref $attrs->{select} ne 'ARRAY' or @{$attrs->{select}} != @pcols );
36 # This is hideously ugly, but SQLA does not understand multicol IN expressions
37 my $sqla = $self->_sql_maker;
38 my ($sql, @bind) = @${$rs->as_query};
39 $sql = sprintf ('(%s) IN %s', # the as_query stuff is already enclosed in ()s
40 join (', ', map { $sqla->_quote ($_) } @pcols),
46 $op eq 'update' ? $values : (),
54 See L<DBIx::Class/CONTRIBUTORS>
58 You may distribute this code under the same terms as Perl itself.