[Dbix-class] DynamicSubclass and Preview: conflict?
luke.saunders at gmail.com
Fri May 7 08:40:03 GMT 2010
On Tue, May 4, 2010 at 3:51 PM, Miquel Ruiz <m.ruiz85 at gmail.com> wrote:
> On 02/05/2010 22:15, Matt S Trout wrote:
>> You're going to want to break stuff out into stages - first, get out of
>> Catalyst code and write yourself a t/ file for your app so once this does
>> work you can't accidentally break it again. Second, that file should do
>> new_result, then insert directly rather than using create(). Third, once
>> you've got that split you can see specifically what blows up. Then you can
>> start dumping $obj->result_source where $obj is either an rs or a row to
>> see which source you've ended up with where and why there's a problem.
>> If you can have a go at the above and then once you get stuck again post
>> your results we can chat about what those results mean and how to debug
>> this further.
> As you recommend, i've been dumping the result sources, and they seem to be
> correct, they are eiher a "DBIx::Class::ResultSource::Table::Previewed" or a
> "DBIx::Class::ResultSource::Table::Preview" depending if the schema has the
> preview activated or not. So this part seems to be working as expected.
> Anyway, i've debugged the test, and this is what i've found:
> When creating a new row via "$items_rs->new_result(\%stuff)", the new()
> method at DBIx::Class::Row is calling, for each given column, the
> "store_column" method.
> Since it is overrided by DynamicSubclass, this method is reblessing "$self"
> to the corresponding class the first time it gets called.
> When "store_column" is called from DBIx::Class::Row with the 'deleted'
> column, it is crashing with the reported error:
> DBIx::Class::ResultSet::new_result(): No such column 'deleted' at test.pl
> line 19
> Attached there is an extract of the debugging session. If somebody is
> interested i can send the whole test case used to test it.
>> Thanks very much for playing along so far - I'm aware it can be a trifle
>> frustrating but we -are- getting somewhere, albeit not as quickly as we
>> might have liked.
> Thanks to you for the help!
> On the other hand i've found something that seems weird to me: the Preview
> is not working if, when creating the schema, the method "compose_namespace"
> is not called. (I mean the Preview component alone, not mixing it with any
> other component)
> As an example:
> This *is* working:
> my $schema = MyApp::Schema->compose_namespace('MyApp')->connect(@dsn);
> This is *not* working:
> my $schema = MyApp::Schema->connect(@dsn);
> In that case it crashes with:
> DBIx::Class::ResultSet::new_result(): No such column deleted on
> MyApp::Schema::Items at ...
> Does anyone know why? If you need the code i can provide it.
I'm responsible for ::Preview so I'll take what you have and make a
failing .t from it against the ::Preview test suit, then I'll figure
out what's happening and how best to fix it. If you don't mind sending
the code then send it to me (offlist) as it may help.
I'll get back to you again once I've made some progress. Feel free to
kick me on irc (lukes on irc.perl.org).
More information about the DBIx-Class