[Dbix-class] Newbie question about relations

Matt S Trout dbix-class at trout.me.uk
Tue Oct 17 11:22:31 CEST 2006


Dave Howorth wrote:
> Diego M. Vadell wrote:
>> Hi,
>>   I am just starting with DBIx::Class and Catalyst, and quite frankly I don't 
>> know much about designing the tables. I decided to start exploring Catalyst 
>> by making a simple file server via web, with sqlite tables:
>>
>> CREATE TABLE Files (
>>             id          INTEGER PRIMARY KEY,
>>             filename       TEXT
>>     );
>>
>>     CREATE TABLE Perms (
>>             file_id     INTEGER,
>>             user_id     INTEGER,
>>             read        BOOLEAN,
>>             del         BOOLEAN,
>>             new         BOOLEAN,
>>             PRIMARY KEY (file_id, user_id)
>>     );
>>     CREATE TABLE Users (
>>             id          INTEGER PRIMARY KEY,
>>             username    TEXT,
>>             password    TEXT
>>     );
>>
>> The idea is that the "Files" tables has a filename, the "Users" have username 
>> and password and "Perms" have the ACL of every file wrt every user. I can 
>> $schema->populate Files and Users, but when I try to do it with Perms, I get:
>>
>> Can't use string ("WFSDB::Perms") as a HASH ref while "strict refs" in use 
>> at /usr/lib/perl5/site_perl/5.8.5/DBIx/Class/InflateColumn.pm line 168.
> 
> Just yesterday, I got this error:
> 
>   Can't use string ("DBSchema::EntryAttributes") as a HASH ref
>   while "strict refs" in use at
>   /usr/lib/perl5/site_perl/5.8.6/DBIx/Class/InflateColumn.pm line 168.
> 
> The good news for me, and perhaps you, is that I know what caused my error!
> 
> This error is DBIC's oh-so-subtle way of telling me that I have a column
> name in my database that conflicts with a DBIC method name. In my case,
> I happen to know it is 'belongs_to'.
> 
> To find out if this is the case for you, run your script in the debugger
> and look at the stack backtrace you get when it dies. For me, the name
> of the column is in the second level down, like this:
> 
>   DBIx::Class::InflateColumn::get_column('DBSchema::EntryAttributes',
>   'belongs_to') called at
>   /usr/lib/perl5/site_perl/5.8.6/DBIx/Class/Row.pm line 241

Ah HELL.

You've got a column called 'new'.

That's ... unlikely to work unless you rename the accessor.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list