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

James Masters james at masters.me.uk
Fri Aug 25 00:00:46 CEST 2006


Thanks for the advice.  I have been re-reading the documentation and have
made some progress by using the Loader Debugger.

Firstly, let me reply to your 2 points.  Of course, I did first try to
use ->load_classes.  This didn't work - the error said I was missing a
module; I can't remember the name of it now but I couldn't find a win32
version of it so gave up and used MG::Schema::Country instead which did
work - after all this was just to prove that I could connect and load data.
Also, when I changed to use Loader, I had thought by using "MG::Main" I was
using a different name to "MG::Schema" - just as you suggest.  Or am I
misunderstanding something?

Anyway, with the debugger, I have learnt that the Loader was working fine. I
can see all the tables, columns and PKs being loaded.  Also I got the
resultsets to work - the problem was that I was specifying CountryCode
(which is indeed the correct name of my column) but to get it to work I have
to use lower case "countrycode".  Someone has told me that this is because
MySQL columns are not case-sensitive and all columns are stored in lower
case.  [ Still, I don't think this is ideal behaviour personally as I like
my "cased" column names.  Wouldn't a better behaviour be for the methods to
accept any case?  Not sure if possible as might mess up other database
interfaces - just wondering. ]

However, I am left with a problem.  The following error:

Attempt to free unreferenced scalar: SV 0x1fa7a5c, Perl interpreter:
0x224234 at C:/Perl/site/lib/SQL/Abstract/Limit.pm line 325.

occurs every time I attempt to use a resultset.  Tinkering has established
that it occurs with each of the following lines.

my @livecountries my $m my @allcountries my $country  my $r my $p 
If I put all 6 lines, it occurs 6 times.  It happens if this is the last
thing in the script.

This only happens when the schema is loaded via Loader - it did not appear
when the schema was loaded via my manually created module. The Loader
debugger does not give any clues.  If anyone can point me in the right
direction for further reading/investigation, I'd be very grateful.

thanks,

James Masters.




  -----Original Message-----
  From: dbix-class-bounces at lists.rawmode.org
[mailto:dbix-class-bounces at lists.rawmode.org]On Behalf Of Brandon Black
  Sent: 24 August 2006 14:28
  To: dbix-class at lists.rawmode.org
  Subject: Re: [Dbix-class] Problem with DBIx::Class::Schema::Loader or





  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 MG::Schema->connect('DBI:mysql:mg', 'jfrm', '???'); #* # 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 MG::Main->connect('DBI:mysql:mg', 'jfrm', '????'); #&
# Query for all countries and put them in an array,my @all_countries $schema->resultset('Country')->all;foreach my $country (@all_countries) {
    print "! ".$country->CountryCode." country->CountryName."<Br>";    }
 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 325Software 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/bba87a5d/attachment.htm 


More information about the Dbix-class mailing list