[CDBI] X is not a column of Y

Arshavir Grigorian grigorian at gmail.com
Sat Oct 6 02:01:27 BST 2007


Following is my class structure that gives the error described in my
first email. I have tried to cut out all the extraneous stuff. The
error only results when deleting the record. And all my packages are
in separate files. Thanks in advance.


Error
---------------------------------------------------------------------------------------------------------------------------
t4 is not a column of App::T1 at
/usr/local/share/perl/5.8.7/Class/DBI/Search/Basic.pm line 115

Code
---------------------------------------------------------------------------------------------------------------------------

package App::DBI;
use base 'Class::DBI';

use strict;

my ($dsn, $username, $password) =
('dbi:Pg:db=dbname;host=localhost','login', 'pass');

App::DBI->set_db('Main',
		    $dsn,
		    $username,
		    $password,
		    {AutoCommit=>1},
		    );
1;


package App::T1;

use strict;
use base 'App::DBI';

__PACKAGE__->table('t1');
__PACKAGE__->columns(All => qw/id t2_id t4_id t5_id type_id t6_id /);
__PACKAGE__->sequence('t1_id_seq');

__PACKAGE__->has_a(t2_id => 'App::T2');
__PACKAGE__->has_a(t4_id     => 'App::T4');
__PACKAGE__->has_a(t5_id    => 'App::T5');

1;

package App::T2;

use strict;
use base 'App::DBI';

__PACKAGE__->table('t2');
__PACKAGE__->columns(All => qw/id t3_id t6_id/);
__PACKAGE__->sequence('t2_id_seq');

__PACKAGE__->has_many ( t1s => 'App::T1',
			{ order_by => 'create_dt' });

__PACKAGE__->has_a ( t3_id => 'App::T3' );

1;

package App::T3;

use strict;
use base 'App::DBI';

__PACKAGE__->table('t3');
__PACKAGE__->columns(Primary => "id");
__PACKAGE__->columns(All => qw/id name t6_id/);
__PACKAGE__->sequence('t3_id_seq');


__PACKAGE__->has_a ( t6_id => 'App::T6');
__PACKAGE__->has_many ( t2s => 'App::T2');
__PACKAGE__->has_many ( t4s => 'App::T4');

1;

package App::T4;

use strict;
use base 'App::DBI';

__PACKAGE__->table('t4');
__PACKAGE__->columns(All => qw/ id t3_id t2_id t6_id /);
__PACKAGE__->sequence('t4_id_seq');

__PACKAGE__->has_a(t2_id => 'App::T2');
__PACKAGE__->has_a(t3_id => 'App::T3');
__PACKAGE__->has_a(t6_id => 'App::T6');

__PACKAGE__->has_many(t1s => 'App::T1');
__PACKAGE__->has_many(t5s => 'App::T5');

1;

package App::T5;

use strict;
use base 'App::DBI';

use constant TODO => 1;
use constant DONE => 2;
use constant ABANDONED => 3;

__PACKAGE__->table('t5');
__PACKAGE__->columns(All => qw/id t3_id t4_id t2_id t1_id t6_id/);
__PACKAGE__->sequence('t5_id_seq');

__PACKAGE__->has_many (t1s => 'App::T1');
__PACKAGE__->has_a (t4_id => 'App::T4');

1;

package App::T6;

use strict;
use base 'App::DBI';

__PACKAGE__->table('t6');
__PACKAGE__->columns(All => qw/id/);

__PACKAGE__->sequence('t6_id_seq');

__PACKAGE__->has_many(companies => 'App::T3');
__PACKAGE__->has_many(t2s  => 'App::T2');
__PACKAGE__->has_many(files     => 'App::Files');

1;


#!/usr/bin/perl

use strict;
use lib qw(.);

use App::DBI;
use App::T1;
use App::T2;
use App::T3;
use App::T4;
use App::T5;
use App::T6;

my $id = 42;

my ($obj) = App::T4->search( id     => $id,
			                    t6_id  => 23 );
print $obj->id();

$obj->delete() if $obj;



On 10/3/07, Edward J. Sabol <sabol at alderaan.gsfc.nasa.gov> wrote:
> Arshavir Grigorian wrote:
> > Hi, I am getting the error posted below when I try to delete from a
> > table that has_many() records in another table. All my classes are
> > defined in separate files and Communication is being loaded before
> > Task where Communication has_a(Task) and T
> > has_many(Communications).
> >
> > Thanks in advance for any suggestions on how to fix this.
>
> Hard to suggest anything without seeing your code for these two classes. Can
> you post some code? I'm not aware of any problems with what you are
> describing. I believe I have classes which mirror the relationships you are
> describing, and they work fine for me.
>
> Later,
> Ed
>



More information about the ClassDBI mailing list