[Bast-commits] r4159 - in
DBIx-Class/0.08/branches/cdbicompat_integration:
lib/DBIx/Class/CDBICompat t/cdbi-t
schwern at dev.catalyst.perl.org
schwern at dev.catalyst.perl.org
Tue Mar 11 01:18:50 GMT 2008
Author: schwern
Date: 2008-03-11 01:18:49 +0000 (Tue, 11 Mar 2008)
New Revision: 4159
Added:
DBIx-Class/0.08/branches/cdbicompat_integration/t/cdbi-t/early_column_heisenbug.t
Modified:
DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/ColumnGroups.pm
Log:
Fixed a heisenbug where looking at a column group would cause it to be shared.
Modified: DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/ColumnGroups.pm
===================================================================
--- DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/ColumnGroups.pm 2008-03-11 00:38:09 UTC (rev 4158)
+++ DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/ColumnGroups.pm 2008-03-11 01:18:49 UTC (rev 4159)
@@ -4,6 +4,8 @@
use strict;
use warnings;
+use Storable 'dclone';
+
use base qw/DBIx::Class::Row/;
__PACKAGE__->mk_classdata('_column_groups' => { });
@@ -29,7 +31,9 @@
sub _register_column_group {
my ($class, $group, @cols) = @_;
- my $groups = { %{$class->_column_groups} };
+ # Must do a complete deep copy else column groups
+ # might accidentally be shared.
+ my $groups = dclone $class->_column_groups;
if ($group eq 'Primary') {
$class->set_primary_key(@cols);
Added: DBIx-Class/0.08/branches/cdbicompat_integration/t/cdbi-t/early_column_heisenbug.t
===================================================================
--- DBIx-Class/0.08/branches/cdbicompat_integration/t/cdbi-t/early_column_heisenbug.t (rev 0)
+++ DBIx-Class/0.08/branches/cdbicompat_integration/t/cdbi-t/early_column_heisenbug.t 2008-03-11 01:18:49 UTC (rev 4159)
@@ -0,0 +1,28 @@
+use strict;
+
+use Test::More;
+
+BEGIN {
+ eval "use DBIx::Class::CDBICompat;";
+ plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@")
+ : ('no_plan');
+}
+
+
+{
+ package Thing;
+ use base qw(DBIx::Class::CDBICompat);
+}
+
+{
+ package Stuff;
+ use base qw(DBIx::Class::CDBICompat);
+}
+
+# There was a bug where looking at a column group before any were
+# set would cause them to be shared across classes.
+is_deeply [Stuff->columns("Essential")], [];
+Thing->columns(Essential => qw(foo bar baz));
+is_deeply [Stuff->columns("Essential")], [];
+
+1;
More information about the Bast-commits
mailing list