6 eval "use DBIx::Class::CDBICompat;";
7 plan $@ ? (skip_all => 'Class::Trigger and DBIx::ContextualFetch required') : (tests=> 24);
11 #-----------------------------------------------------------------------
12 # Make sure that we can set up columns properly
13 #-----------------------------------------------------------------------
16 use base 'DBIx::Class::Test::SQLite';
18 State->table('State');
19 State->columns(Essential => qw/Abbreviation Name/);
20 State->columns(Primary => 'Name');
21 State->columns(Weather => qw/Rain Snowfall/);
22 State->columns(Other => qw/Capital Population/);
23 #State->has_many(cities => "City");
26 my ($class, $column) = @_;
27 my $return = $column eq "Rain" ? "Rainfall" : $column;
32 my ($class, $column) = @_;
33 my $return = $column eq "Rain" ? "set_Rainfall" : "set_$column";
42 use base 'DBIx::Class::Test::SQLite';
45 City->columns(All => qw/Name State Population/);
46 City->has_a(State => 'State');
49 #-------------------------------------------------------------------------
51 use base 'DBIx::Class::Test::SQLite';
54 CD->columns('All' => qw/artist title length/);
56 #-------------------------------------------------------------------------
60 is(State->table, 'State', 'State table()');
61 is(State->primary_column, 'name', 'State primary()');
62 is_deeply [ State->columns('Primary') ] => [qw/name/],
63 'State Primary:' . join ", ", State->columns('Primary');
64 is_deeply [ sort State->columns('Essential') ] => [qw/abbreviation name/],
65 'State Essential:' . join ", ", State->columns('Essential');
66 is_deeply [ sort State->columns('All') ] =>
67 [ sort qw/name abbreviation rain snowfall capital population/ ],
68 'State All:' . join ", ", State->columns('All');
70 is(CD->primary_column, 'artist', 'CD primary()');
71 is_deeply [ CD->columns('Primary') ] => [qw/artist/],
72 'CD primary:' . join ", ", CD->columns('Primary');
73 is_deeply [ sort CD->columns('All') ] => [qw/artist length title/],
74 'CD all:' . join ", ", CD->columns('All');
75 is_deeply [ sort CD->columns('Essential') ] => [qw/artist/],
76 'CD essential:' . join ", ", CD->columns('Essential');
78 ok(State->find_column('Rain'), 'find_column Rain');
79 ok(State->find_column('rain'), 'find_column rain');
80 ok(!State->find_column('HGLAGAGlAG'), '!find_column HGLAGAGlAG');
84 can_ok +State => qw/Rainfall _Rainfall_accessor set_Rainfall
85 _set_Rainfall_accessor Snowfall _Snowfall_accessor set_Snowfall
86 _set_Snowfall_accessor/;
88 foreach my $method (qw/Rain _Rain_accessor rain snowfall/) {
89 ok !State->can($method), "State can't $method";
96 skip "No column objects", 1;
98 eval { my @grps = State->__grouper->groups_for("Huh"); };
99 ok $@, "Huh not in groups";
102 my @grps = sort State->__grouper->groups_for(State->_find_columns(qw/rain capital/));
103 is @grps, 2, "Rain and Capital = 2 groups";
104 @grps = sort @grps; # Because the underlying API is hash-based
105 is $grps[0], 'Other', " - Other";
106 is $grps[1], 'Weather', " - Weather";
112 # @DieTest::ISA = qw(DBIx::Class);
113 # DieTest->load_components(qw/CDBICompat::Retrieve Core/);
115 # local $SIG{__WARN__} = sub { };
116 # eval { DieTest->retrieve(1) };
117 # like $@, qr/unless primary columns are defined/, "Need primary key for retrieve";
120 #-----------------------------------------------------------------------
121 # Make sure that columns inherit properly
122 #-----------------------------------------------------------------------
126 @A::ISA = qw(DBIx::Class);
127 __PACKAGE__->load_components(qw/CDBICompat Core/);
128 __PACKAGE__->table('dummy');
129 __PACKAGE__->columns(Primary => 'id');
133 __PACKAGE__->table('dummy2');
134 __PACKAGE__->columns(All => qw(id b1));
138 __PACKAGE__->table('dummy3');
139 __PACKAGE__->columns(All => qw(id c1 c2 c3));
142 is join (' ', sort A->columns), 'id', "A columns";
143 is join (' ', sort A::B->columns), 'b1 id', "A::B columns";
144 is join (' ', sort A::C->columns), 'c1 c2 c3 id', "A::C columns";