[Dbix-class] CDBI->DBIx::Class migration question

Nic Gibson nicg at corbas.net
Thu Oct 18 07:34:22 GMT 2007


Good morning

I'm in the middle of moving a large bunch of code from CDBI to
DBIx::Class. Pretty
well everything has worked perfectly except...

We have a stored procedure wrapper for CDBI. It allows us to create
functions, accessors  and mutators that call SPs (in PostgreSQL).

We can mostly emulate this by creating resultsources I reckon.
I'm wondering if there is a DBIx::Class way to handle mutators. In CDBI we have
something like:

__PACKAGE__->sp_mutator(method_name =>
	{procedure => 'procname',
	argcount => 2,
	modifies => [qw/list of columns/]});
	
which creates sql something like:

	'select * from procname(?, ?, ?)'
	
where procname has side effects that change the source table (the number of
arguments being 'argcount' plus the number of primary key columns).

Then, in code, we can do

	$object->method_name($arg1, $arg2);
	
The stored procedure will be called with the primary key of $object as
the first
argument (assuming it has a single column PK)
	
The columns in the modifies list are then cleared and CDBI will reload
them for us.

Now, the DBIx::Class 'way' seems to be much more result set based which makes
me think this might not be easy in the DBIx::Class model. Is it worth
the effort for me to
try to port this or should I just just unroll the complex sps into
small steps that I can
easily handle by calling from perl?

cheers

nic
-- 
Nic Gibson
Director, Corbas Consulting
Editorial and Technical Consultancy
http://www.corbas.co.uk/



More information about the DBIx-Class mailing list