Skip Menu |

This queue is for tickets about the Fey-ORM CPAN distribution.

Report information
The Basics
Id: 77988
Status: resolved
Priority: 0/
Queue: Fey-ORM

People
Owner: Nobody in particular
Requestors: mdengfeng [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Can't call method "new" on an undefined value at /opt/perl-5.16.0/lib/site_perl/5.16.0/Fey/Meta/HasOne/ViaFK.pm line 50.
Date: Sun, 24 Jun 2012 15:20:47 +0800
To: bug-Fey-ORM [...] rt.cpan.org
From: DengFeng Mao <mdengfeng [...] gmail.com>
HI, Expert I just tried the Fey-ORM-0.44 with Perl-5.16.0 in for simple mysql database schema. But I got the following error. ======================= Can't call method "new" on an undefined value at /opt/perl-5.16.0/lib/site_perl/5.16.0/Fey/Meta/HasOne/ViaFK.pm line 50. ======================== Here is the output of 'perl -V' ============ perl -V Summary of my perl5 (revision 5 version 16 subversion 0) configuration: Platform: osname=linux, osvers=2.6.18-194.el5, archname=x86_64-linux-thread-multi uname='linux grape 2.6.18-194.el5 #1 smp tue mar 16 21:52:39 edt 2010 x86_64 x86_64 x86_64 gnulinux ' config_args='-Dcc=gcc -Dusethreads -Duse64bitall -Dprefix=/opt/perl-5.16.0/ -de' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.1.2 20080704 (Red Hat 4.1.2-48)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64 libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.5.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Built under linux Compiled at Jun 24 2012 11:44:01 @INC: /opt/perl-5.16.0/lib/site_perl/5.16.0/x86_64-linux-thread-multi /opt/perl-5.16.0/lib/site_perl/5.16.0 /opt/perl-5.16.0/lib/5.16.0/x86_64-linux-thread-multi /opt/perl-5.16.0/lib/5.16.0 ============= I install Fey::ORM by cpan command. All tests are OK. Here is my database schema: ==================== -- -- table `group` -- DROP TABLE IF EXISTS `group`; CREATE TABLE IF NOT EXISTS `group` ( `group_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, PRIMARY KEY (`group_id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- insert data into `group` -- INSERT INTO `group` (`group_id`, `name`) VALUES (1, 'admin'), (2, 'developer'), (3, 'guest'), (4, 'QA'); -- -------------------------------------------------------- -- -- table `message` -- DROP TABLE IF EXISTS `message`; CREATE TABLE IF NOT EXISTS `message` ( `message_id` int(11) NOT NULL AUTO_INCREMENT, `message` text NOT NULL, `message_date` date NOT NULL, `parent_message_id` int(11) DEFAULT NULL, `user_id` int(11) NOT NULL, PRIMARY KEY (`message_id`), KEY `user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- insert `message` -- INSERT INTO `message` (`message_id`, `message`, `message_date`, `parent_message_id`, `user_id`) VALUES (1, 'How to learn Perl quickly?', '2012-06-01', NULL, 1), (2, 'Some books can help you. \r\n-- Camel books.', '2012-06-02', 1, 2), (3, 'perldoc is the online help document.\r\nIt''s command line tool.\r\nYou can refer it at any time', '2012-06-03', 1, 3), (5, 'Some useful BBS forum also can help you.\r\nwww.perlmonks.org\r\ nwww.pm.org', '2012-06-03', 1, 4), (6, 'What''s the famous movie in this summer', '2012-06-11', NULL, 6), (7, '1.Savages\r\n2.Easy Money\r\n3.The amazing spider man\r\n', '2012-06-11', 6, 7), (8, '-- Ice Age: Continental Drift \r\n-- Crazy eyes', '2012-06-12', 6, 8); -- -------------------------------------------------------- -- -- table `user` -- DROP TABLE IF EXISTS `user`; CREATE TABLE IF NOT EXISTS `user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(128) NOT NULL, `email` varchar(128) DEFAULT NULL, `group_id` int(11) NOT NULL, PRIMARY KEY (`user_id`), UNIQUE KEY `username` (`username`), KEY `group_id` (`group_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- \u8f6c\u5b58\u8868\u4e2d\u7684\u6570\u636e `user` -- INSERT INTO `user` (`user_id`, `username`, `email`, `group_id`) VALUES (1, 'Lincon', 'lincon@yahoo.com', 2), (2, 'Michael Scofield', 'mike@preason.break', 3), (3, 'Raymond', 'raymond@yahoo.com', 4), (4, 'Debora', 'debora@hotmail.com', 2), (5, 'Franklin', 'franklin@facebook.com', 2), (6, 'Steve', 'steve@android.com', 3), (7, 'Jane', 'jane@gmail.com', 4), (8, 'admin', 'admin@voole.com', 1); -- -- table `message` -- ALTER TABLE `message` ADD CONSTRAINT `message_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON UPDATE CASCADE; -- -- table `user` -- ALTER TABLE `user` ADD CONSTRAINT `user_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `group` (`group_id`) ON UPDATE CASCADE; ==================== Here is my database model for message table ============== package Forum::Model::Message; use strict; use warnings; use Forum::Model::Schema; use Fey::ORM::Table; has_table( Forum::Model::Schema->Schema()->table('message') ); has_one ( Forum::Model::Schema->Schema()->table('user') ); ==================== Here is my simple test script -- msg.pl ==== use strict; use warnings; use utf8; use lib ('./lib'); use Forum::Model::Message; use Data::Dumper; my $msg = Forum::Model::Message->new('message_id' => 1 ); my $user = $msg->user; ===== I have tried to dump the $msg object. It seems it's right. But the error was prompt when call $msg->user; Can't call method "new" on an undefined value at /opt/perl-5.16.0/lib/site_perl/5.16.0/Fey/Meta/HasOne/ViaFK.pm line 50. I guess there are some incompatibilities among Fey::ORM, MooseX, Moose modules. Could you help to look into this issue ? Thanks Dengfeng -- --------------------------------------------------------- Market is wrong, But I am right! -- --------------------------------------------------------- Market is wrong, But I am right!
Subject: Re: [rt.cpan.org #77988] Can't call method "new" on an undefined value at /opt/perl-5.16.0/lib/site_perl/5.16.0/Fey/Meta/HasOne/ViaFK.pm line 50.
Date: Tue, 26 Jun 2012 10:59:30 -0500 (CDT)
To: DengFeng Mao via RT <bug-Fey-ORM [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Sun, 24 Jun 2012, DengFeng Mao via RT wrote: Show quoted text
> ============== > > > package Forum::Model::Message; > use strict; > use warnings; > > use Forum::Model::Schema; > > use Fey::ORM::Table; > > has_table( Forum::Model::Schema->Schema()->table('message') ); > > has_one ( Forum::Model::Schema->Schema()->table('user') ); > > ==================== > > Here is my simple test script -- msg.pl > > > ==== > use strict; > use warnings; > use utf8; > > use lib ('./lib'); > > use Forum::Model::Message; > use Data::Dumper; > > my $msg = Forum::Model::Message->new('message_id' => 1 ); > > my $user = $msg->user; > > > ===== > > > I have tried to dump the $msg object. It seems it's right. But the error > was prompt when call $msg->user; > > Can't call method "new" on an undefined value at > /opt/perl-5.16.0/lib/site_perl/5.16.0/Fey/Meta/HasOne/ViaFK.pm line 50.
This is happening because there is no class associated with the user table. Try putting a "use Forum::Model::User" call into the Message class. I'm guessing this isn't getting loaded. Show quoted text
> I guess there are some incompatibilities among Fey::ORM, MooseX, Moose > modules.
I doubt it. This would manifest in a very different way. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
Subject: Re: [rt.cpan.org #77988] Can't call method "new" on an undefined value at /opt/perl-5.16.0/lib/site_perl/5.16.0/Fey/Meta/HasOne/ViaFK.pm line 50.
Date: Wed, 27 Jun 2012 11:27:17 +0800
To: bug-Fey-ORM [...] rt.cpan.org
From: DengFeng Mao <mdengfeng [...] gmail.com>
Thanks for your reply. Yep, you are right. The root-cause is that 'use Forum::Model::User' was missing in 'Forum::Model::Message' package. The error message is so abstract. It can't help me to identify the root-cause. Thanks for your help again. Dengfeng 2012/6/26 autarch@urth.org via RT <bug-Fey-ORM@rt.cpan.org> Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=77988 > > > On Sun, 24 Jun 2012, DengFeng Mao via RT wrote: >
> > ============== > > > > > > package Forum::Model::Message; > > use strict; > > use warnings; > > > > use Forum::Model::Schema; > > > > use Fey::ORM::Table; > > > > has_table( Forum::Model::Schema->Schema()->table('message') ); > > > > has_one ( Forum::Model::Schema->Schema()->table('user') ); > > > > ==================== > > > > Here is my simple test script -- msg.pl > > > > > > ==== > > use strict; > > use warnings; > > use utf8; > > > > use lib ('./lib'); > > > > use Forum::Model::Message; > > use Data::Dumper; > > > > my $msg = Forum::Model::Message->new('message_id' => 1 ); > > > > my $user = $msg->user; > > > > > > ===== > > > > > > I have tried to dump the $msg object. It seems it's right. But the error > > was prompt when call $msg->user; > > > > Can't call method "new" on an undefined value at > > /opt/perl-5.16.0/lib/site_perl/5.16.0/Fey/Meta/HasOne/ViaFK.pm line 50.
> > This is happening because there is no class associated with the user > table. Try putting a "use Forum::Model::User" call into the Message class. > I'm guessing this isn't getting loaded. >
> > I guess there are some incompatibilities among Fey::ORM, MooseX, Moose > > modules.
> > I doubt it. This would manifest in a very different way. > > > -dave > > /*============================================================ > http://VegGuide.org http://blog.urth.org > Your guide to all that's veg House Absolute(ly Pointless) > ============================================================*/ > >
-- --------------------------------------------------------- Market is wrong, But I am right!