i am getting the following error when trying to auto_initialize a  
table class from a custom $dbh:

   Could not auto-retrieve primary key columns for class My::Junk -  
no primary key info found for catalog '' schema '' table 'junk'


the table is very simple:

mysql> create table junk ( junk_id int auto_increment primary key,  
name varchar(32) ) ;
Query OK, 0 rows affected (0.09 sec)

mysql> show create table junk\G
*************************** 1. row ***************************
        Table: junk
Create Table: CREATE TABLE `junk` (
   `junk_id` int(11) NOT NULL auto_increment,
   `name` varchar(32) default NULL,
   PRIMARY KEY  (`junk_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

mysql> insert into junk set name = 'one' ;
Query OK, 1 row affected (0.01 sec)

mysql> insert into junk set name = 'two' ;
Query OK, 1 row affected (0.00 sec)

mysql> select * from junk ;
+---------+------+
| junk_id | name |
+---------+------+
|       1 | one  |
|       2 | two  |
+---------+------+
2 rows in set (0.01 sec)



here is my test script:

% cat auto.pl
#!perl
use strict; use warnings;

## Set up $dbh
use Vinq::Globals qw($dbh);
BEGIN { Vinq::Globals->init(confName => 'plexmreece') }

BEGIN {
     ## verify $dbh is working
     my $sth = $dbh->prepare('SELECT COUNT(1) FROM junk');
     $sth->execute;

     print "got ", $sth->fetchrow_array, " junks from dbh $dbh\n";
}

package My::Junk;
use base 'Rose::DB::Object';
use Vinq::Globals qw($dbh);

sub init_db {
     print "Setting up Rose::DB with dbh => $dbh\n";
     return Rose::DB->new(dbh => $dbh, driver => 'mysql');
}

__PACKAGE__->meta->table('junk');
__PACKAGE__->meta->auto_initialize;


and here is the output:

% perl auto.pl
got 2 junks from dbh Vinq::DB=HASH(0x8832a74)
Setting up Rose::DB with dbh => Vinq::DB=HASH(0x8832a74)
Setting up Rose::DB with dbh => Vinq::DB=HASH(0x8832a74)
Setting up Rose::DB with dbh => Vinq::DB=HASH(0x8832a74)
Could not auto-retrieve primary key columns for class My::Junk - no  
primary key info found for catalog '' schema '' table 'junk' at  
auto.pl line 28



am i missing something?  do i need to tell Rose::DB more about the  
dbh i am injecting?

% perl -MRose::DB -MRose::DB::Object -e 'print "Rose::DB  
$Rose::DB::VERSION\nRose::DB::Object $Rose::DB::Object::VERSION\n"'
Rose::DB 0.732
Rose::DB::Object 0.760



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to