[Dbix-class] Problem with DBIx::Class::Schema::Loader or

Brandon Black blblack at gmail.com
Thu Aug 24 15:27:42 CEST 2006


On 8/24/06, James Masters <james at masters.me.uk> wrote:
>
>  I have DBIx::Class working using mysql on win32 . Here's my code  which
> is just designed to test the concept using a single table in my DB:
>
> # set up a schema class using 2 modules that I've written manually
> use MG::Schema::Tables;   # *
> use MG::Schema::Country;  # *
> my $schema >
> # Or better, fill the class with table info automatically (using a file called MG/Main.pm with content:
> #package MG::Main;
> #use base qw/DBIx::Class::Schema::Loader/;
> #__PACKAGE__->loader_options(
> #    relationships           => 1);
>
> #use MG::Main;    #&
> #my $schema >
> # Query for all countries and put them in an array,
> my @all_countries > foreach my $country (@all_countries) {
>     print "! ".$country->CountryCode." >     }
>
> So then I want to change to not have to write all the schemas out manually into modules by using the  DBIx::Class::Schema::Loader module.
> I just want to load them all into memory automatically.
> So I comment out the 3 lines labelled #* and uncomment the 2 lines with #&. Here's the error:
>
> [Wed Aug 23 18:22:49 2006] mgdb.pl: Attempt to free unreferenced scalar: SV 0x1fa7a5c, Perl interpreter: 0x224234 at C:/Perl/site/lib/SQL/Abstract/Limit.pm line 325.
> [Wed Aug 23 18:22:49 2006] mgdb.pl:  at C:/Perl/site/lib/SQL/Abstract/Limit.pm line 325
> Software error:
> Can't locate object method "CountryCode" via package "MG::Main::Country" at C:/Information/mgroot/cgi-bin/mgdb.pl line 53.
>  at C:/Information/mgroot/cgi-bin/mgdb.pl line 53
>
>
>
> Is this because I'm doing something wrong due to my very poor
> understanding of object methods?  (in which case your suggestions would be
> extremely welcome)
>
> Or is it a bug in this  SQL::Abstract::Limit module .  (in which case I'll
> do my best to put in a bug report if i can work out how  - Do I put it as
> a bug report for DBIx::Class::Schema::Loader or SQL::Abstract::Limit)?
>
> thanks for any advice.
>

I would  suggest re-reading the related docs and tutorials.  First, you
should not have to "use MG::Schema::Country" anywhere.  Only the Schema
class itself uses that, and it does so via ->load_classes.  Everything uses
should just "use MG::Schema".  Secondly, its not enough to get rid of your
useless "use" statements when you switch to Schema::Loader.  Either give the
Loader-based schema a completely different name (MG::LoaderSchema ?) or
delete/move all of your manual files, or there will be issues with the two
overlapping.  That should start you moving in the right general direction.

-- Brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060824/57e123f9/attachment.htm 


More information about the Dbix-class mailing list