[Dbix-class] oracle sequence auto-pk patch

Johannes Plunien plu at pqpq.de
Thu Sep 6 10:53:13 GMT 2007


Hi,

thanks to mst who posted yesterday a few lines of code:

2007-09-05 19:31:40 <@mst> sub insert { my ($self, $source,  
$to_insert) = @_; foreach my $pri ($source->primary_columns) { if (! 
defined $to_insert->{$pri}) { my $col_info = $source->column_info 
($pri); if ($col_info->{auto_nextval}) { $to_insert->{$pri} = $self- 
 >_sequence_fetch('nextval',$col_info->{sequence}); } } $self- 
 >next::method($source, $to_insert); }
2007-09-05 19:32:44 <@mst> sub _sequence_fetch { my ($self, $type,  
$seq) = @_; $self->_dbh_do("SELECT ${seq}.${type} FROM DUAL"); }

So now here's the patch with some test *attached*
What does it do? You can use oracle & dbic with an autoincremental  
sequence WITHOUT using an oracle trigger.
So finally ".. insert a row with a primary key that uses a sequence?"  
from DBIx::Class::Manual::FAQ works :)

Kind regards,
plu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: oracle_sequence.patch
Type: application/octet-stream
Size: 5088 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070906/0aac6353/oracle_sequence-0001.obj
-------------- next part --------------

--
Johannes Plunien | mailto:plu at pqpq.de | http://www.pqpq.de




More information about the DBIx-Class mailing list