1 package DBIx::Class::CDBICompat;
5 use base qw/DBIx::Class::Core DBIx::Class::DB/;
6 use Carp::Clan qw/^DBIx::Class/;
9 require Class::Trigger;
10 require DBIx::ContextualFetch;
12 croak "Class::Trigger and DBIx::ContextualFetch is required for CDBICompat" if $@;
14 __PACKAGE__->load_own_components(qw/
40 #DBIx::Class::ObjIndexStubs
45 DBIx::Class::CDBICompat - Class::DBI Compatibility layer.
49 use base qw/DBIx::Class/;
50 __PACKAGE__->load_components(qw/CDBICompat Core DB/);
54 DBIx::Class features a fully featured compatibility layer with L<Class::DBI>
55 and L<Class::DBI::AbstractSearch> to ease transition for existing CDBI users.
57 In fact, this class is just a receipe containing all the features emulated.
58 If you like, you can choose which features to emulate by building your
59 own class and loading it like this:
61 __PACKAGE__->load_own_components(qw/CDBICompat/);
63 this will automatically load the features included in My::DB::CDBICompat,
64 provided it looks something like this:
66 package My::DB::CDBICompat;
67 __PACKAGE__->load_components(qw/
68 CDBICompat::ColumnGroups
81 The following methods and classes are not emulated, maybe in the future.
85 =item Class::DBI::Query
87 Deprecated in Class::DBI.
89 =item Class::DBI::Column
91 Not documented in Class::DBI. CDBICompat's columns() returns a plain string, not an object.
95 Undocumented CDBI method.
99 =head2 Limited Support
101 The following elements of Class::DBI have limited support.
105 =item Class::DBI::Relationship
107 The semi-documented Class::DBI::Relationship objects returned by C<meta_info($type, $col)> are mostly emulated except for their C<args> method.
111 Relationships between tables (has_a, has_many...) must be delcared after all tables in the relationship have been declared. Thus the usual CDBI idiom of declaring columns and relationships for each class together will not work. They must instead be done like so:
114 use base qw(Class::DBI);
117 Foo->columns( All => qw(this that bar) );
120 use base qw(Class::DBI);
123 Bar->columns( All => qw(up down) );
125 # Now that Foo and Bar are declared it is safe to declare a
126 # relationship between them
127 Foo->has_a( bar => "Bar" );
134 Matt S. Trout <mst@shadowcatsystems.co.uk>
138 You may distribute this code under the same terms as Perl itself.