lib/DBIx/Class/Optional/Dependencies.pod
pm_to_blib
t/var/
+.*.sw?
(RT#64795)
- Work around a Firebird ODBC driver bug exposed by DBD::ODBC 1.29
- Fix exiting via next warnings in ResultSource::sequence()
+ - Fix stripping of table qualifiers in update/delete in arrayref
+ condition elements
* Misc
- Only load Class::C3 and friends if necessary ($] < 5.010)
gphat: Cory G Watson <gphat@cpan.org>
+Grant Street Group L<http://www.grantstreet.com/>
+
groditi: Guillermo Roditi <groditi@cpan.org>
Haarg: Graham Knop <haarg@haarg.org>
_resolve_column_info
_prune_unused_joins
_strip_cond_qualifiers
+ _strip_cond_qualifiers_from_array
_resolve_aliastypes_from_select_args
_execute
_do_query
# at all. What this code tries to do (badly) is introspect the condition
# and remove all column qualifiers. If it bails out early (returns undef)
# the calling code should try another approach (e.g. a subquery)
+
+sub _strip_cond_qualifiers_from_array {
+ my ($self, $where) = @_;
+ my @cond;
+ for (my $i = 0; $i < @$where; $i++) {
+ my $entry = $where->[$i];
+ my $hash;
+ my $ref = ref $entry;
+ if ($ref eq 'HASH' or $ref eq 'ARRAY') {
+ $hash = $self->_strip_cond_qualifiers($entry);
+ }
+ elsif (! $ref) {
+ $entry =~ /([^.]+)$/;
+ $hash->{$1} = $where->[++$i];
+ }
+ push @cond, $hash;
+ }
+ return \@cond;
+}
+
sub _strip_cond_qualifiers {
my ($self, $where) = @_;
return $cond unless $where;
if (ref $where eq 'ARRAY') {
- $cond = [
- map {
- my %hash;
- foreach my $key (keys %{$_}) {
- $key =~ /([^.]+)$/;
- $hash{$1} = $_->{$key};
- }
- \%hash;
- } @$where
- ];
+ $cond = $self->_strip_cond_qualifiers_from_array($where);
}
elsif (ref $where eq 'HASH') {
if ( (keys %$where) == 1 && ( (keys %{$where})[0] eq '-and' )) {
- $cond->{-and} = [];
- my @cond = @{$where->{-and}};
- for (my $i = 0; $i < @cond; $i++) {
- my $entry = $cond[$i];
- my $hash;
- my $ref = ref $entry;
- if ($ref eq 'HASH' or $ref eq 'ARRAY') {
- $hash = $self->_strip_cond_qualifiers($entry);
- }
- elsif (! $ref) {
- $entry =~ /([^.]+)$/;
- $hash->{$1} = $cond[++$i];
- }
- else {
- $self->throw_exception ("_strip_cond_qualifiers() is unable to handle a condition reftype $ref");
- }
- push @{$cond->{-and}}, $hash;
- }
+ $cond->{-and} =
+ $self->_strip_cond_qualifiers_from_array($where->{-and});
}
else {
foreach my $key (keys %$where) {
my $init_count = $artist_rs->count;
ok ($init_count, 'Some artists is database');
-$artist_rs->populate ([
- {
- name => 'foo',
- },
- {
- name => 'bar',
- }
-]);
-
-is ($artist_rs->count, $init_count + 2, '2 Artists created');
-
-$artist_rs->search ({
- -and => [
- { 'me.artistid' => { '!=', undef } },
+foreach my $delete_arg (
[ { 'me.name' => 'foo' }, { 'me.name' => 'bar' } ],
- ],
-})->delete;
-
-is ($artist_rs->count, $init_count, 'Correct amount of artists deleted');
+ [ 'me.name' => 'foo', 'me.name' => 'bar' ],
+) {
+ $artist_rs->populate ([
+ {
+ name => 'foo',
+ },
+ {
+ name => 'bar',
+ }
+ ]);
+
+ is ($artist_rs->count, $init_count + 2, '2 Artists created');
+
+ $artist_rs->search ({
+ -and => [
+ { 'me.artistid' => { '!=', undef } },
+ $delete_arg,
+ ],
+ })->delete;
+
+ is ($artist_rs->count, $init_count, 'Correct amount of artists deleted');
+}
done_testing;