[Dbix-class] compoase_namespace, add_column, and result_source_instance

Christopher H. Laco claco at chrislaco.com
Sat Jul 8 17:07:04 CEST 2006


OK, this is my last post on the subject. I need to eat, and the wife
actually wants to interact with me rather than watch me curse at the
computer all morning.

The talk of add_columns and Handel is a side road carnival show. It's a
symptom of another problem.

I believe that problem is this: compose_namespace clones a schema, then
creates new classes. The result of compose_namespace is a schema object
in which its sources are new, not the original sources, and the source
classes are new, also not the originals. The fault lie inthe fact that
the new source classes aren't tied to the new source objects via
result_source_instance.

Instead, class->result_source_instance is inherited, and still points to
the original pre-cloned sources.

The following patch fixes the problem for me, and the basic test suite
still passes for me. I can't speak for the mysql/pg tests. Someone
please try those just for the sake of my sanity.

> Index: lib/DBIx/Class/Schema.pm
> ===================================================================
> --- lib/DBIx/Class/Schema.pm	(revision 2145)
> +++ lib/DBIx/Class/Schema.pm	(working copy)
> @@ -390,6 +390,7 @@
>          $target_class => $source->result_class, ($base ? $base : ())
>        );
>        $source->result_class($target_class);
> +      $target_class->result_source_instance($source);
>      }
>    }
>    Class::C3->reinitialize();


The code actually speaks to my theory I think.
The new sources' result_class is associated with the new class, but the
reverse wasn't true.

I wouldn't dare commit this since the topic is somewhat complicated. :-)

-=Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060708/ba06ee85/attachment.pgp 


More information about the Dbix-class mailing list