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

Matt S Trout dbix-class at trout.me.uk
Thu Nov 13 19:28:48 GMT 2008


On Tue, Oct 21, 2008 at 02:44:43PM +0200, Bernhard Graf wrote:
> > 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.

Don't be so grumpy, people were telling you the best way to get to what
you were trying to achieve, rather than merely what you seemed to want to
implement.

We're all helping for free, so our instinct tends to be to try and teach
people the best way to do things given the avaialable tools rather than just
hack around their current problem.
 
> 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 => '...'});

Yep. That's because we're going to need a lot of work to make it possible
to pass the aliased name to search() so we prefer to keep the resultset
methods consistent that way - so the 'accessor' arg, as its name suggests,
only alters the accessor name.

Fixing such things would be something I'd like to see for 09; I'll try and
include the prereqs in my "09 analysis" document which should turn up on
the list ion the next week or so.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list