use List::Util 'first';
use Try::Tiny;
use DBIx::Class::Carp;
-use SQL::Abstract 'is_literal_value';
+use SQL::Abstract qw( is_literal_value is_plain_value );
###
### Internal method
unless exists $self->{_column_data}{$column} || $self->result_source->has_column($column);
$self->throw_exception( "set_column called for ${column} without value" )
if @_ < 3;
- return $self->{_column_data}{$column} = $value;
+
+ # stringify all refs explicitly, guards against overloaded objects
+ # with defined stringification AND fallback => 0 (ugh!)
+ $self->{_column_data}{$column} = ( length ref $value and is_plain_value( $value ) )
+ ? "$value"
+ : $value
+ ;
}
=head2 inflate_result
use lib qw(t/lib);
use DBICTest;
use DBIx::Class::_Util qw(sigwarn_silencer serialize);
-use Path::Class::File ();
use Math::BigInt;
use List::Util qw/shuffle/;
+{
+ package DBICTest::StringifiesOnly;
+ use overload
+ '""' => sub { $_[0]->[0] },
+ fallback => 0,
+ ;
+}
+{
+ package DBICTest::StringifiesViaFallback;
+ use overload
+ 'bool' => sub { $_[0]->[0] },
+ ;
+}
+
my $schema = DBICTest->init_schema();
# The map below generates stuff like:
# the stringification has nothing to do with the artist name
# this is solely for testing consistency
- my $fn = Path::Class::File->new ('somedir/somefilename.tmp');
- my $fn2 = Path::Class::File->new ('somedir/someotherfilename.tmp');
+ my $fn = bless [ 'somedir/somefilename.tmp' ], 'DBICTest::StringifiesOnly';
+ my $fn2 = bless [ 'somedir/someotherfilename.tmp' ], 'DBICTest::StringifiesViaFallback';
my $rank = Math::BigInt->new(42);
my $args = {
};
# generate the AoH equivalent based on the AoAs above
+ # also generate the expected HRI output ( is_deeply is too smart for its own good )
for my $bag (values %$args) {
$bag->{AoH} = [];
+ $bag->{Expected} = [];
my @hdr = @{$bag->{AoA}[0]};
for my $v ( @{$bag->{AoA}}[1..$#{$bag->{AoA}}] ) {
push @{$bag->{AoH}}, my $h = {};
@{$h}{@hdr} = @$v;
+
+ push @{$bag->{Expected}}, my $hs = {};
+ @{$hs}{@hdr} = map { "$_" } @$v;
}
}
$rs->populate($args->{$tst}{$type});
is_deeply(
$rs->all_hri,
- $args->{$tst}{AoH},
+ $args->{$tst}{Expected},
"Populate() $tst in void context"
);
my $dummy = $rs->populate($args->{$tst}{$type});
is_deeply(
$rs->all_hri,
- $args->{$tst}{AoH},
+ $args->{$tst}{Expected},
"Populate() $tst in non-void context"
);
my @dummy = $rs->populate($args->{$tst}{$type});
is_deeply(
$rs->all_hri,
- $args->{$tst}{AoH},
+ $args->{$tst}{Expected},
"Populate() $tst in non-void context"
);
}
is_deeply(
$rs->all_hri,
- $args->{$tst}{AoH},
+ $args->{$tst}{Expected},
"Create() $tst"
);
}