[Bast-commits] r7812 - in DBIx-Class/0.08/trunk/lib/DBIx/Class: .
Storage
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Thu Oct 22 09:10:39 GMT 2009
Author: caelum
Date: 2009-10-22 09:10:38 +0000 (Thu, 22 Oct 2009)
New Revision: 7812
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
Log:
stringify values passed to populate/insert_bulk
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2009-10-21 14:33:45 UTC (rev 7811)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm 2009-10-22 09:10:38 UTC (rev 7812)
@@ -1796,8 +1796,10 @@
} else {
my ($first, @rest) = @$data;
+ require overload;
my @names = grep {
- (not ref $first->{$_}) || (ref $first->{$_} eq 'SCALAR')
+ (not ref $first->{$_}) || (ref $first->{$_} eq 'SCALAR') ||
+ (overload::Method($first->{$_}, '""'))
} keys %$first;
my @rels = grep { $self->result_source->has_relationship($_) } keys %$first;
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2009-10-21 14:33:45 UTC (rev 7811)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2009-10-22 09:10:38 UTC (rev 7812)
@@ -1352,22 +1352,20 @@
next unless ref $first_val eq 'SCALAR';
$colvalues{ $cols->[$i] } = $first_val;
-## This is probably unnecessary since $rs->populate only looks at the first
-## slice anyway.
-# if (grep {
-# ref $_ eq 'SCALAR' && $$_ eq $$first_val
-# } map $data->[$_][$i], (1..$#$data)) == (@$data - 1);
}
- # check for bad data
+ # check for bad data and stringify stringifiable objects
my $bad_slice = sub {
my ($msg, $col_idx, $slice_idx) = @_;
$self->throw_exception(sprintf "%s for column '%s' in populate slice:\n%s",
$msg,
$cols->[$col_idx],
- Data::Dumper::Concise::Dumper({
- map { $cols->[$_] => $data->[$slice_idx][$_] } (0 .. $#$cols)
- }),
+ do {
+ local $Data::Dumper::Maxdepth = 1; # don't dump objects, if any
+ Data::Dumper::Concise::Dumper({
+ map { $cols->[$_] => $data->[$slice_idx][$_] } (0 .. $#$cols)
+ }),
+ }
);
};
@@ -1393,8 +1391,14 @@
}
}
elsif (my $reftype = ref $val) {
- $bad_slice->("$reftype reference found where bind expected",
- $col_idx, $datum_idx);
+ require overload;
+ if (overload::Method($val, '""')) {
+ $datum->[$col_idx] = "".$val;
+ }
+ else {
+ $bad_slice->("$reftype reference found where bind expected",
+ $col_idx, $datum_idx);
+ }
}
}
}
More information about the Bast-commits
mailing list