Re: [Maypole] Error: "has_a needs a valid column"

From: Joshua Keroes (jkeroes at eli.net)
Date: Sat Oct 23 2004 - 01:48:03 BST


>> Am Donnerstag, den 21.10.2004, 18:33 -0700 schrieb Joshua Keroes:
>>> Can't get some simple code to work. I've searched for this error
>>> through the Maypole archives, in both Wikis, on google; nothing. I'd
>>> love some help.

Thanks, Dave and Sebastien,

Thanks you two, the project is up and running. I had to remove the
trailing slash from <Location "/projects"> and now everything is
running almost perfectly.

Almost? Yeah, dang. There seems to be a misfire from this line:

        __PACKAGE__->config->{uri_base} = "http://localhost/projects/";

The trailing slash disappears from the links to other table views on
http://localhost/projects/project/list/

In other words, there are two tables (engineer, project), and two tabs
at the top of the above webpage, one for each. Each URL points to
http://localhost/projectsengineer/list/ or
http://localhost/projectsproject/list/ respectively. There should be
another '/' in the middle of those URLs.

I haven't started debugging this yet. I've tried changing some settings
here and there. I'll whip out perl -d in a heartbeat if there isn't a
simple answer to this.

---

Almost perfect item number two:

CDBI::Loader::Relationship isn't doing the right thing when I request a has_many relationship. has_a works just fine. I'm trying to say that any project can have one or more engineers working on it.

I've been tracing through this in the debugger all day and don't see why this shouldn't work (tests trimmed for brevity):

use Test::More tests => 9; use Class::DBI::Loader; use Class::DBI::Loader::Relationship;

ok $loader = Class::DBI::Loader->new( dsn => "dbi:mysql:projects", user => 'projects', password => 'projects', ), 'new() CDBI::Loader::Relationship';

ok $loader->relationship( 'a project has an engineer' ), 'a project has an engineer';

can_ok Engineer => 'eng_id'; can_ok Engineer => 'first_name'; can_ok Engineer => 'last_name'; can_ok Project => 'project_id'; can_ok Project => 'name'; can_ok Project => 'description';

# XXX This fails: ok $loader->relationship( 'a project has engineers' ), 'a project has engineers';

__END__

The last test fails with error message: "has_a needs a valid column at /usr/local/lib/site_perl/5.8.1/Class/DBI/Relationship/HasA.pm line 12"

Note: I realize that it's a little sloppy building both a has_a relationship as well as a has_many in the same file. Separating the calls into separate files yields the same behavior so it's a wash.

I'm working with:

CREATE TABLE engineer ( eng_id int(11) NOT NULL auto_increment, first_name varchar(128) NOT NULL default '', last_name varchar(128) NOT NULL default '', PRIMARY KEY (eng_id) ) TYPE=InnoDB;

CREATE TABLE project ( project_id int(11) NOT NULL auto_increment, name varchar(128) NOT NULL default '', cfr mediumint(9) default NULL, description text, start_date date NOT NULL default '0000-00-00', end_date date default NULL, status text, status_date date default NULL, engineer int(11) default NULL, is_complete tinyint(1) default NULL, PRIMARY KEY (project_id) ) TYPE=InnoDB;

Thank-you all again, very much, Joshua

_______________________________________________ maypole mailing list maypole at lists.netthink.co.uk http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT