[Dbix-class] Q: Differing column names in DBIC and SQL

Jess Robinson castaway at desert-island.me.uk
Tue Oct 21 14:49:46 BST 2008


On Tue, 21 Oct 2008, Bernhard Graf wrote:

> Jess Robinson wrote:
>
>> I haven't heard/seen this "common practice" anywhere.. But if you're
>
> Well I did. The only I remember right now is Lyris list server.
>
>> determined, you want to define your columns as:
>>
>>    _name => {
>>       accessor => 'name',
>>       data_type => 'varchar',
>>       ..
>>    }
>>
>> To get the deploy system to create them with underscores in your
>> database, while accessing them using the non-underscored versions in
>> your code.
>
> Thank you Jess. Finally I get an answer to my actual question.
>
> I tried the above, but this seems half-baken:
> While deploy() works as expected, and also accessing the column with
> $rs->name() works, using the name in an argument list is not supported.
> You still have to say:
> $rs->create({_name => '...'});

Oops, I forgot to mention that minor hiccup. Yup, that's the way it works 
for now..

You could patch SQL::Translator::Parser::DBIx::Class (in the dbic dist 
package) to use the name => .. key in the column_info.. then you could use 
as you first mentioned and deploy (which uses sqlt) would work.

Jess




More information about the DBIx-Class mailing list