Centralize all user-side rsrc calls to go through result_source()
authorPeter Rabbitson <ribasushi@cpan.org>
Thu, 14 Apr 2016 22:33:17 +0000 (00:33 +0200)
committerPeter Rabbitson <ribasushi@cpan.org>
Mon, 25 Jul 2016 12:42:53 +0000 (14:42 +0200)
commite570488ade8f327f47dd3318db3443a348d561d6
treeb75e32972f33f0ced0d96be91906194917207778
parentb83736a7d3235d2f50fe5695550eb3637432d960
Centralize all user-side rsrc calls to go through result_source()

This ensures the user will always get a sensible exception when the rsrc
metadata object has not yet been initialized (as introduced in 5298bbb5):

Before:
 ~$ perl -e 'use base "DBIx::Class::Core"; __PACKAGE__->add_column("foo")'
 Can't locate object method "result_source_instance" via package "main" at .../ResultSourceProxy.pm line 29.

After:
 ~$ perl -e 'use base "DBIx::Class::Core"; __PACKAGE__->add_column("foo")'
 DBIx::Class::Row::result_source(): No ResultSource instance registered for 'main', did you forget to call main->table(...) ? at -e line 1

Add a shitload of assertions to track we are doing the right thing in all
cases. This more or less concludes the rsrc changeset necessary to resolve
all ambiguities. The next commit adds user-visible warnings when things go
off the rails

The changeset was successfully tested against the list of distributions
in c8b1011e with no ill effects being observed. Thus I am pretty damn
confident I rather nailed it >.>
22 files changed:
lib/DBIx/Class/CDBICompat/ColumnCase.pm
lib/DBIx/Class/CDBICompat/ColumnGroups.pm
lib/DBIx/Class/CDBICompat/ImaDBI.pm
lib/DBIx/Class/CDBICompat/Relationships.pm
lib/DBIx/Class/DB.pm
lib/DBIx/Class/InflateColumn.pm
lib/DBIx/Class/Manual/Cookbook.pod
lib/DBIx/Class/Relationship/BelongsTo.pm
lib/DBIx/Class/Relationship/HasMany.pm
lib/DBIx/Class/Relationship/HasOne.pm
lib/DBIx/Class/ResultSetManager.pm
lib/DBIx/Class/ResultSource.pm
lib/DBIx/Class/ResultSource/View.pm
lib/DBIx/Class/ResultSourceProxy.pm
lib/DBIx/Class/ResultSourceProxy/Table.pm
lib/DBIx/Class/Row.pm
lib/DBIx/Class/Schema.pm
lib/DBIx/Class/UTF8Columns.pm
lib/DBIx/Class/_Util.pm
t/lib/DBICTest.pm
t/lib/DBICTest/BaseSchema.pm
t/resultsource/instance_equivalence.t