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.

Thank you all very much.

--
Miquel Ruiz - CAPSiDE

$ perl -d test.pl

Loading DB routines from perl5db.pl version 1.28
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:10):     print `rm db`;
  DB<1> b DBIx::Class::Row::new
  DB<2> c
...

  DB<2> n
DBIx::Class::Row::new(/usr/share/perl5/DBIx/Class/Row.pm:238):
238:          $new->store_column($key => $attrs->{$key});
  DB<2> print $new
MyApp::Items::preview=HASH(0x8909a94)
  DB<3> n
DBIx::Class::Row::new(/usr/share/perl5/DBIx/Class/Row.pm:171):
171:          if (ref $attrs->{$key}) {
  DB<3> print $new
MyApp::Schema::Items::Service=HASH(0x8909a94)

...


  DB<6>
DBIx::Class::Row::new(/usr/share/perl5/DBIx/Class/Row.pm:238):
238:          $new->store_column($key => $attrs->{$key});
  DB<6> print $key
deleted
  DB<6> n
 at /usr/share/perl5/DBIx/Class/Exception.pm line 68
        DBIx::Class::Exception::throw('DBIx::Class::Exception', 'No such column 
\'deleted\'', 0) called at /usr/share/perl5/DBIx/Class/Schema.pm line 994
        DBIx::Class::Schema::throw_exception('MyApp::Schema=HASH(0x890a0c4)', 
'No such column \'deleted\'') called at /usr/share/perl5/DBIx/Class/Row.pm line 
1230
        
DBIx::Class::Row::throw_exception('MyApp::Schema::Items::Service=HASH(0x8909a94)',
 'No such column \'deleted\'') called at /usr/share/perl5/DBIx/Class/Row.pm 
line 956
        
DBIx::Class::Row::store_column('MyApp::Schema::Items::Service=HASH(0x8909a94)', 
'deleted', 0) called at /usr/share/perl5/DBIx/Class/DynamicSubclass.pm line 203
        
DBIx::Class::DynamicSubclass::store_column('MyApp::Schema::Items::Service=HASH(0x8909a94)',
 'deleted', 0) called at /usr/share/perl5/DBIx/Class/Row.pm line 238
        DBIx::Class::Row::new('MyApp::Items::preview', 'HASH(0x87b9474)') 
called at /usr/share/perl5/DBIx/Class/DynamicSubclass.pm line 166
        DBIx::Class::DynamicSubclass::new('MyApp::Items::preview', 
'HASH(0x87b9474)') called at /usr/share/perl5/DBIx/Class/Preview.pm line 155
        DBIx::Class::Preview::new('MyApp::Items::preview', 'HASH(0x87b9474)') 
called at /usr/share/perl5/DBIx/Class/ResultSet.pm line 1787
        
DBIx::Class::ResultSet::new_result('DBIx::Class::ResultSet=HASH(0x890a2ec)', 
'HASH(0x8909f8c)') called at test.pl line 19
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<6> q

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to