Subject: | CDBICompat does not allow columns to be set before table. |
In CDBI this is perfectly kosher.
Foo->columns( Essential => qw(this that) );
Foo->table('foo');
But CDBICompat blows up
Can't locate object method "result_source_instance" via package "Foo" at
lib/DBIx/Class/CDBICompat/ColumnCase.pm line 17.
The problem is table() is being used as a convenient place to initialize
the table_class instance and stick it into the class'
result_source_instance(). If that already existed, even if the object
were empty, there would be no problem.
A test is attached.
Subject: | columns_before_table.t |
#!/usr/bin/perl -w
use strict;
use Test::More;
BEGIN {
eval "use DBIx::Class::CDBICompat;";
plan $@ ? (skip_all => 'Class::Trigger and DBIx::ContextualFetch required')
: (tests=> 2);
}
# Make sure that we can set up columns properly
package State;
use base 'DBIx::Class::Test::SQLite';
eval {
State->columns(Essential => qw/Abbreviation Name/);
State->table("State");
};
::is $@, '', 'columns() can be called before table()';
::is_deeply [sort map lc, State->columns("Essential")],
[sort map lc, qw(abbreviation name)];