From: Christopher H. Laco Date: Thu, 10 May 2007 00:18:35 +0000 (+0000) Subject: resultset_class/result_class now (again) auto loads the specified class; requires... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fac560c2bcc31d5ab5f981abc521a41501cb1e8a;p=dbsrgits%2FDBIx-Class-Historic.git resultset_class/result_class now (again) auto loads the specified class; requires Class::Accessor::Grouped 0.05000+ --- diff --git a/Changes b/Changes index 3742a33..7b23bac 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,8 @@ Revision history for DBIx::Class - The SQL::T parser class now respects a relationship attribute of is_foreign_key_constrain to allow explicit control over wether or not a foreign constraint is needed + - resultset_class/result_class now (again) auto loads the specified + class; requires Class::Accessor::Grouped 0.05000+ 0.07006 2007-04-17 23:18:00 - Lots of documentation updates @@ -308,7 +310,8 @@ Revision history for DBIx::Class 0.05002 2006-02-06 12:12:03 - Added recommends for Class::Inspector - - Added skip_all to t/40resultsetmanager.t if no Class::Inspector available + - Added skip_all to t/40resultsetmanager.t if no Class::Inspector + available 0.05001 2006-02-05 15:28:10 - debug output now prints NULL for undef params @@ -348,8 +351,10 @@ Revision history for DBIx::Class 0.04999_04 2006-01-24 21:48:21 - more documentation improvements - - add columns_info_for for vendor-specific column info (Zbigniew Lukasiak) - - add SQL::Translator::Producer for DBIx::Class table classes (Jess Robinson) + - add columns_info_for for vendor-specific column info (Zbigniew + Lukasiak) + - add SQL::Translator::Producer for DBIx::Class table classes (Jess + Robinson) - add unique constraint declaration (Daniel Westermann-Clark) - add new update_or_create method (Daniel Westermann-Clark) - rename ResultSetInstance class to ResultSetProxy, ResultSourceInstance @@ -359,11 +364,13 @@ Revision history for DBIx::Class 0.04999_03 2006-01-20 06:05:27 - imported Jess Robinson's SQL::Translator::Parser::DBIx::Class - - lots of internals cleanup to eliminate result_source_instance requirement + - lots of internals cleanup to eliminate result_source_instance + requirement - added register_column and register_relationship class APIs - made Storage::DBI use prepare_cached safely (thanks to Tim Bunce) - many documentation improvements (thanks guys!) - - added ->connection, ->connect, ->register_source and ->clone schema methods + - added ->connection, ->connect, ->register_source and ->clone schema + methods - Use croak instead of die for user errors. 0.04999_02 2006-01-14 07:17:35 @@ -436,3 +443,4 @@ Revision history for DBIx::Class 0.01 2005-08-08 17:10:00 - initial release + diff --git a/Makefile.PL b/Makefile.PL index 1d64d0c..26d90ed 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -15,7 +15,7 @@ requires 'Carp::Clan' => 0; requires 'DBI' => 1.40; requires 'Module::Find' => 0; requires 'Class::Inspector' => 0; -requires 'Class::Accessor::Grouped' => 0.03; +requires 'Class::Accessor::Grouped' => 0.05000; requires 'JSON' => 1.00; # Perl 5.8.0 doesn't have utf8::is_utf8() diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 54374f1..4bb6ff6 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -14,7 +14,7 @@ __PACKAGE__->mk_group_accessors('simple' => qw/_ordered_columns _columns _primaries _unique_constraints name resultset_attributes schema from _relationships column_info_from_storage source_info/); -__PACKAGE__->mk_group_accessors('inherited' => qw/resultset_class +__PACKAGE__->mk_group_accessors('component_class' => qw/resultset_class result_class/); __PACKAGE__->mk_group_ro_accessors('simple' => qw/source_name/); diff --git a/t/resultset_class.t b/t/resultset_class.t new file mode 100644 index 0000000..078c57b --- /dev/null +++ b/t/resultset_class.t @@ -0,0 +1,22 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More; +use Class::Inspector (); + +unshift(@INC, './t/lib'); +use lib 't/lib'; +plan tests => 5; + +use DBICTest; + +is(DBICTest::Schema->source('Artist')->resultset_class, 'DBIx::Class::ResultSet', 'default resultset class'); +ok(!Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class not loaded'); +DBICTest::Schema->source('Artist')->resultset_class('DBICNSTest::ResultSet::A'); +ok(Class::Inspector->loaded('DBICNSTest::ResultSet::A'), 'custom resultset class loaded automatically'); +is(DBICTest::Schema->source('Artist')->resultset_class, 'DBICNSTest::ResultSet::A', 'custom resultset class set'); + +my $schema = DBICTest->init_schema; +my $resultset = $schema->resultset('Artist')->search; +isa_ok($resultset, 'DBICNSTest::ResultSet::A', 'resultset is custom class');