diff -ruN --exclude='.*' --exclude='*.db' DBIx-Class-VirtualColumns-1.01/lib/DBIx/Class/VirtualColumns.pm DBIx-Class-VirtualColumns-1.01.new/lib/DBIx/Class/VirtualColumns.pm
--- DBIx-Class-VirtualColumns-1.01/lib/DBIx/Class/VirtualColumns.pm 2008-05-22 12:15:49.000000000 -0500
+++ DBIx-Class-VirtualColumns-1.01.new/lib/DBIx/Class/VirtualColumns.pm 2009-11-21 22:28:45.000000000 -0600
@@ -184,6 +184,10 @@
sub _virtual_filter {
my ($self,$attrs) = @_;
+
+ if ( !$self->_virtual_columns ) {
+ $self->_virtual_columns( {} );
+ }
my $virtual_attrs = {};
my $main_attrs = {};
diff -ruN --exclude='.*' --exclude='*.db' DBIx-Class-VirtualColumns-1.01/t/006_relation.t DBIx-Class-VirtualColumns-1.01.new/t/006_relation.t
--- DBIx-Class-VirtualColumns-1.01/t/006_relation.t 1969-12-31 18:00:00.000000000 -0600
+++ DBIx-Class-VirtualColumns-1.01.new/t/006_relation.t 2009-11-21 22:34:19.000000000 -0600
@@ -0,0 +1,39 @@
+# -*- perl -*-
+
+# t/006_relation.t -- Test relationship stuff
+
+use Class::C3;
+use strict;
+use Test::More;
+use warnings;
+no warnings qw(once);
+
+BEGIN {
+ eval "use DBD::SQLite";
+ plan $@
+ ? ( skip_all => 'needs DBD::SQLite for testing' )
+ : ( tests => 3 );
+}
+
+use lib qw(t/lib);
+
+use_ok( 'VCTest' );
+
+use_ok( 'VCTest::Schema' );
+
+my $schema = VCTest->init_schema();
+
+# Make sure we can still get a Test2 w/o adding a virtual column
+my $test3;
+eval { $test3 = $schema->resultset('Test2')->create({
+ id => "12",
+ name => "nayme",
+ test3 => {
+ id => "12",
+ name => "other nayme",
+ },
+}); };
+ok( !$@, 'Create row with relation that has loaded VC but has no VCs defined' )
+or diag ( $@ );
+
+
diff -ruN --exclude='.*' --exclude='*.db' DBIx-Class-VirtualColumns-1.01/t/lib/VCTest/Schema/Test2.pm DBIx-Class-VirtualColumns-1.01.new/t/lib/VCTest/Schema/Test2.pm
--- DBIx-Class-VirtualColumns-1.01/t/lib/VCTest/Schema/Test2.pm 2008-05-21 08:55:19.000000000 -0500
+++ DBIx-Class-VirtualColumns-1.01.new/t/lib/VCTest/Schema/Test2.pm 2009-11-21 22:26:19.000000000 -0600
@@ -23,5 +23,6 @@
},
);
__PACKAGE__->set_primary_key('id');
-
-1;
\ No newline at end of file
+__PACKAGE__->might_have( test3 => 'VCTest::Schema::Test3', 'id' );
+
+1;
diff -ruN --exclude='.*' --exclude='*.db' DBIx-Class-VirtualColumns-1.01/t/lib/VCTest/Schema/Test3.pm DBIx-Class-VirtualColumns-1.01.new/t/lib/VCTest/Schema/Test3.pm
--- DBIx-Class-VirtualColumns-1.01/t/lib/VCTest/Schema/Test3.pm 1969-12-31 18:00:00.000000000 -0600
+++ DBIx-Class-VirtualColumns-1.01.new/t/lib/VCTest/Schema/Test3.pm 2009-11-21 22:23:07.000000000 -0600
@@ -0,0 +1,22 @@
+package # Hide from PAUSE
+ VCTest::Schema::Test3;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components(qw/VirtualColumns PK::Auto Core/);
+__PACKAGE__->table("test3");
+__PACKAGE__->add_columns(
+ "id",
+ {
+ data_type => "integer",
+ is_nullable => 0,
+ },
+ "name",
+ {
+ data_type => "varchar",
+ is_nullable => 0,
+ },
+);
+__PACKAGE__->set_primary_key('id');
+
+1;
diff -ruN --exclude='.*' --exclude='*.db' DBIx-Class-VirtualColumns-1.01/t/lib/VCTest/Schema.pm DBIx-Class-VirtualColumns-1.01.new/t/lib/VCTest/Schema.pm
--- DBIx-Class-VirtualColumns-1.01/t/lib/VCTest/Schema.pm 2008-05-21 08:23:54.000000000 -0500
+++ DBIx-Class-VirtualColumns-1.01.new/t/lib/VCTest/Schema.pm 2009-11-21 22:24:40.000000000 -0600
@@ -3,6 +3,6 @@
use base qw/DBIx::Class::Schema/;
-__PACKAGE__->load_classes(qw/Test1 Test2/);
+__PACKAGE__->load_classes(qw/Test1 Test2 Test3/);
-1;
\ No newline at end of file
+1;
diff -ruN --exclude='.*' --exclude='*.db' DBIx-Class-VirtualColumns-1.01/t/var/vctest.sql DBIx-Class-VirtualColumns-1.01.new/t/var/vctest.sql
--- DBIx-Class-VirtualColumns-1.01/t/var/vctest.sql 2008-05-21 09:54:58.000000000 -0500
+++ DBIx-Class-VirtualColumns-1.01.new/t/var/vctest.sql 2009-11-21 22:25:57.000000000 -0600
@@ -2,6 +2,7 @@
DROP TABLE IF EXISTS test1;
DROP TABLE IF EXISTS test2;
+DROP TABLE IF EXISTS test3;
CREATE TABLE test1 (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -15,4 +16,9 @@
description TEXT
);
+CREATE TABLE test3 (
+ id INTEGER PRIMARY KEY,
+ name TEXT NOT NULL
+);
+
COMMIT;