use strict;
use warnings;
use Sub::Name ();
-use Storable 'dclone';
use List::Util ();
use base qw/DBIx::Class::Row/;
# Must do a complete deep copy else column groups
# might accidentally be shared.
- my $groups = dclone $class->_column_groups;
+ my $groups = DBIx::Class::_Util::deep_clone( $class->_column_groups );
if ($group eq 'Primary') {
$class->set_primary_key(@cols);
sub _extend_meta {
my ($class, $type, $rel, $val) = @_;
- my %hash = %{ Clone::clone($class->__meta_info || {}) };
+
+### Explicitly not using the deep cloner as Clone exhibits specific behavior
+### wrt CODE references - it simply passes them as-is to the new structure
+### (without deparse/eval cycles). There likely is code that relies on this
+### so we just let sleeping dogs lie.
+ my $hash = Clone::clone($class->__meta_info || {});
$val->{self_class} = $class;
$val->{type} = $type;
$val->{accessor} = $rel;
- $hash{$type}{$rel} = DBIx::Class::CDBICompat::Relationship->new($val);
- $class->__meta_info(\%hash);
+ $hash->{$type}{$rel} = DBIx::Class::CDBICompat::Relationship->new($val);
+ $class->__meta_info($hash);
}
sub qsub ($) { goto "e_sub } # no point depping on new Moo just for this
# END pre-Moo2 import block
+# Already correctly prototyped: perlbrew exec perl -MStorable -e 'warn prototype \&Storable::dclone'
+BEGIN { *deep_clone = \&Storable::dclone }
+
use base 'Exporter';
our @EXPORT_OK = qw(
sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_lt
fail_on_internal_wantarray fail_on_internal_call
refdesc refcount hrefaddr is_exception
- quote_sub qsub perlstring serialize
+ quote_sub qsub perlstring serialize deep_clone
UNRESOLVABLE_CONDITION
);
use Test::Warn;
use lib qw(t/lib);
use DBICTest;
-use DBIx::Class::_Util 'sigwarn_silencer';
+use DBIx::Class::_Util qw(sigwarn_silencer serialize);
use Path::Class::File ();
use Math::BigInt;
use List::Util qw/shuffle/;
-use Storable qw/nfreeze dclone/;
my $schema = DBICTest->init_schema();
}
local $Storable::canonical = 1;
- my $preimage = nfreeze($args);
+ my $preimage = serialize($args);
for my $tst (keys %$args) {
}
ok (
- ($preimage eq nfreeze($args)),
+ ($preimage eq serialize($args)),
'Arguments fed to populate()/create() unchanged'
);
use Test::More;
use lib qw(t/lib);
use DBICTest;
-use Storable qw/dclone/;
my $schema = DBICTest->init_schema();
$pager = $it->pager;
is ($qcnt, 0, 'No queries on rs/pager creation');
-$it = do { local $DBIx::Class::ResultSourceHandle::thaw_schema = $schema; dclone ($it) };
+# test *requires* it to be Storable
+$it = do {
+ local $DBIx::Class::ResultSourceHandle::thaw_schema = $schema;
+ Storable::dclone ($it);
+};
is ($qcnt, 0, 'No queries on rs/pager freeze/thaw');
is( $it->pager->entries_on_this_page, 1, "entries_on_this_page ok for page 2" );
$rs->create({ title => 'bah', artist => 1, year => 2011 });
$qcnt = 0;
-$it = do { local $DBIx::Class::ResultSourceHandle::thaw_schema = $schema; dclone ($it) };
+# test *requires* it to be Storable
+$it = do {
+ local $DBIx::Class::ResultSourceHandle::thaw_schema = $schema;
+ Storable::dclone ($it);
+};
is ($qcnt, 0, 'No queries on rs/pager freeze/thaw');
is( $it->pager->entries_on_this_page, 1, "entries_on_this_page ok for page 2, even though underlying count changed" );
use lib qw(t/lib);
use DBICTest ':DiffSQL';
-
-use Storable 'dclone';
+use DBIx::Class::_Util 'serialize';
my $schema = DBICTest->init_schema();
# A search() with prefetch seems to pollute an already joined resultset
# in a way that offsets future joins (adapted from a test case by Debolaz)
{
- my ($cd_rs, $attrs);
+ my ($cd_rs, $preimage);
# test a real-life case - rs is obtained by an implicit m2m join
$cd_rs = $schema->resultset ('Producer')->first->cds;
- $attrs = dclone( $cd_rs->{attrs} );
+ $preimage = serialize $cd_rs->{attrs};
$cd_rs->search ({})->all;
- is_deeply (dclone($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after a simple search');
+ is ( serialize $cd_rs->{attrs}, $preimage, 'Resultset attributes preserved after a simple search');
lives_ok (sub {
$cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
- is_deeply (dclone($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after search with prefetch');
+ is ( serialize $cd_rs->{attrs}, $preimage, 'Resultset attributes preserved after search with prefetch');
}, 'first prefetching search ok');
lives_ok (sub {
$cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
- is_deeply (dclone($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after another search with prefetch')
+ is ( serialize $cd_rs->{attrs}, $preimage, 'Resultset attributes preserved after another search with prefetch')
}, 'second prefetching search ok');
# test a regular rs with an empty seen_join injected - it should still work!
$cd_rs = $schema->resultset ('CD');
$cd_rs->{attrs}{seen_join} = {};
- $attrs = dclone( $cd_rs->{attrs} );
+ $preimage = serialize $cd_rs->{attrs};
$cd_rs->search ({})->all;
- is_deeply (dclone($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after a simple search');
+ is ( serialize $cd_rs->{attrs}, $preimage, 'Resultset attributes preserved after a simple search');
lives_ok (sub {
$cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
- is_deeply (dclone($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after search with prefetch');
+ is ( serialize $cd_rs->{attrs}, $preimage, 'Resultset attributes preserved after search with prefetch');
}, 'first prefetching search ok');
lives_ok (sub {
$cd_rs->search ({'artist.artistid' => 1}, { prefetch => 'artist' })->all;
- is_deeply (dclone($cd_rs->{attrs}), $attrs, 'Resultset attributes preserved after another search with prefetch')
+ is ( serialize $cd_rs->{attrs}, $preimage, 'Resultset attributes preserved after another search with prefetch')
}, 'second prefetching search ok');
}
use Test::More;
use Test::Exception;
-use Storable 'dclone';
use lib qw(t/lib);
use DBICTest ':DiffSQL';
+use DBIx::Class::_Util 'deep_clone';
my $schema = DBICTest->init_schema;
my $native_limit_dialect = $schema->storage->sql_maker->{limit_dialect};
@where_bind,
@group_bind,
@having_bind,
- @{ dclone \@order_bind }, # without this is_deeply throws a fit
+ @{ deep_clone \@order_bind }, # without this is_deeply throws a fit
],
],
limit_offset_prefetch => [
@where_bind,
@group_bind,
@having_bind,
- @{ dclone \@order_bind }, # without this is_deeply throws a fit
+ @{ deep_clone \@order_bind }, # without this is_deeply throws a fit
],
],
limit_offset_prefetch => [